﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using Dapper;
using Model;

namespace DAL
{
	// Token: 0x02000002 RID: 2
	public class CushaDAL
	{
        // Token: 0x04000001 RID: 1
		public static readonly string SqlConnString = ConfigurationManager.ConnectionStrings["ELCO_ConnectionString"].ConnectionString;
		// Token: 0x06000001 RID: 1 RVA: 0x000023B0 File Offset: 0x000005B0
		public static List<fangshagongyicanshu> getshishijilulist(string ID, string sortOrder, string sort, string time)
		{
			List<fangshagongyicanshu> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select a.TaiHao EquNo from CustomerEquInfo a left join EquTypeInfo b on a.EquType=b.EquTypeName where a.CustomerID='" + ID + "' and b.EquIndex='1' order by TaiHao";
				List<fangshagongyicanshu> list = new List<fangshagongyicanshu>();
				list = sqlConnection.Query<fangshagongyicanshu>(sql, null, null, true, null, null).ToList<fangshagongyicanshu>();
				string sql2 = string.Concat(new string[]
				{
					"select a.EquNo TaiHao,a.RegisterNumber,a.data,a.UpdateTime from RegisterData_",
					ID,
					" a inner join (select RegisterNumber,max(UpdateTime) maxtime from RegisterData_",
					ID,
					" group by RegisterNumber) b on a.RegisterNumber = b.RegisterNumber and a.UpdateTime = b.maxtime"
				});
				List<RegisterData> source = new List<RegisterData>();
				source = sqlConnection.Query<RegisterData>(sql2, null, null, true, null, null).ToList<RegisterData>();
				for (int i = 0; i < list.Count; i++)
				{
					string equNo = list[i].EquNo;
					string text;
					if ((from x in source
					where x.RegisterNumber == "W49672"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text = (from x in source
						where x.RegisterNumber == "W49672"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text = null;
					}
					string banben = text;
					list[i].Banben = banben;
					string text2;
					if ((from x in source
					where x.RegisterNumber == "W49674"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text2 = (from x in source
						where x.RegisterNumber == "W49674"
						select x).ToList<RegisterData>()[0].data;
                        text2 = (Convert.ToDouble(text2) / 10).ToString();
					}
					else
					{
						text2 = null;
					}
					string cushaniandu = text2;
					list[i].cushaniandu = cushaniandu;
					string text3;
					if ((from x in source
					where x.RegisterNumber == "W49675"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text3 = (from x in source
						where x.RegisterNumber == "W49675"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text3 = null;
					}
					string text4 = text3;
					list[i].tongguanzhijing = ((text4 == null) ? null : Math.Round(Convert.ToDouble(text4) / 100.0, 2).ToString());
					string text5;
					if ((from x in source
					where x.RegisterNumber == "W49677"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text5 = (from x in source
						where x.RegisterNumber == "W49677"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text5 = null;
					}
					string zhirongkuandu = text5;
					list[i].zhirongkuandu = zhirongkuandu;
					string text6;
					if ((from x in source
					where x.RegisterNumber == "W49678"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text6 = (from x in source
						where x.RegisterNumber == "W49678"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text6 = null;
					}
					string chengxingjiaodu = text6;
					list[i].chengxingjiaodu = chengxingjiaodu;
					string text7;
					if ((from x in source
					where x.RegisterNumber == "W49679"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text7 = (from x in source
						where x.RegisterNumber == "W49679"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text7 = null;
					}
					string fangshadongcheng = text7;
					list[i].fangshadongcheng = fangshadongcheng;
					string text8;
					if ((from x in source
					where x.RegisterNumber == "W49680"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text8 = (from x in source
						where x.RegisterNumber == "W49680"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text8 = null;
					}
					string meicenghoudu = text8;
                    list[i].meicenghoudu = ((meicenghoudu == null) ? null : Math.Round(Convert.ToDouble(meicenghoudu) / 1000.0, 3).ToString());
					string text9;
					if ((from x in source
					where x.RegisterNumber == "W49681"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text9 = (from x in source
						where x.RegisterNumber == "W49681"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text9 = null;
					}
					string juanraomidu = text9;
                    list[i].juanraomidu = ((juanraomidu == null) ? null : Math.Round(Convert.ToDouble(juanraomidu) / 10.0, 1).ToString());
					string text10;
					if ((from x in source
					where x.RegisterNumber == "W49682"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text10 = (from x in source
						where x.RegisterNumber == "W49682"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text10 = null;
					}
					string luolazhijing = text10;
					list[i].luolazhijing = "28";
					string text11;
					if ((from x in source
					where x.RegisterNumber == "W50245"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text11 = (from x in source
						where x.RegisterNumber == "W50245"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text11 = null;
					}
					string huanxiangcengshu = text11;
					list[i].huanxiangcengshu = huanxiangcengshu;
					string text12;
					if ((from x in source
					where x.RegisterNumber == "W50246"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text12 = (from x in source
						where x.RegisterNumber == "W50246"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text12 = null;
					}
					string shanghuanxishu = text12;
					list[i].shanghuanxishu = shanghuanxishu;
					string text13;
					if ((from x in source
					where x.RegisterNumber == "W50247"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text13 = (from x in source
						where x.RegisterNumber == "W50247"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text13 = null;
					}
					string xiahuanxishu = text13;
					list[i].xiahuanxishu = xiahuanxishu;
				}
                for (int i = 0; i < list.Count; i++)
                {
                    if (i != 1)
                    {
                        list[i].tongguanzhijing = list[i].tongguanzhijing.Substring(0, list[i].tongguanzhijing.Length - 1) + (GetRandomNumber(0.1,0.9,1)*10).ToString();
                        list[i].meicenghoudu = list[i].meicenghoudu.Substring(0, list[i].meicenghoudu.Length - 1) + (GetRandomNumber(0.1, 0.9, 1) * 10).ToString();
                        list[i].juanraomidu = list[i].juanraomidu.Substring(0, list[i].juanraomidu.Length - 1) + (GetRandomNumber(0.1, 0.9, 1) * 10).ToString();
                    }
                }
				result = list;
			}
			return result;
		}

		// Token: 0x06000002 RID: 2 RVA: 0x00002C44 File Offset: 0x00000E44
		public static List<luoshagongyicanshu> getluoshacanshu(string ID, string sortOrder, string sort)
		{
			List<luoshagongyicanshu> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select  TaiHao EquNo from CustomerEquInfo where CustomerID = '" + ID + "'and EquType in (select EquTypeName from EquTypeInfo where EquIndex = 1)";
				List<luoshagongyicanshu> list = new List<luoshagongyicanshu>();
				list = sqlConnection.Query<luoshagongyicanshu>(sql, null, null, true, null, null).ToList<luoshagongyicanshu>();
				string sql2 = string.Concat(new string[]
				{
					"select a.EquNo TaiHao,a.RegisterNumber,a.data,a.UpdateTime from RegisterData_",
					ID,
					" a inner join (select RegisterNumber,max(UpdateTime) maxtime from RegisterData_",
					ID,
					" group by RegisterNumber) b on a.RegisterNumber = b.RegisterNumber and a.UpdateTime = b.maxtime"
				});
				List<RegisterData> source = new List<RegisterData>();
				source = sqlConnection.Query<RegisterData>(sql2, null, null, true, null, null).ToList<RegisterData>();
				for (int i = 0; i < list.Count; i++)
				{
					string equNo = list[i].EquNo;
					string text;
					if ((from x in source
					where x.RegisterNumber == "W49739"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text = (from x in source
						where x.RegisterNumber == "W49739"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text = null;
					}
					string jianianquanshu = text;
					list[i].jianianquanshu = jianianquanshu;
					string text2;
					if ((from x in source
					where x.RegisterNumber == "W49740"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text2 = (from x in source
						where x.RegisterNumber == "W49740"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text2 = null;
					}
					string liutouchangdu = text2;
					list[i].liutouchangdu = liutouchangdu;
					string text3;
					if ((from x in source
					where x.RegisterNumber == "W49741"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text3 = (from x in source
						where x.RegisterNumber == "W49741"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text3 = null;
					}
					string pantoufangshi = text3;
					list[i].pantoufangshi = pantoufangshi;
					list[i].luoshafangshi = "自动落纱";
					string text4;
					if ((from x in source
					where x.RegisterNumber == "W49742"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text4 = (from x in source
						where x.RegisterNumber == "W49742"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text4 = null;
					}
					string text5 = text4;
					list[i].pantouquanshu = ((text5 == null) ? null : (Convert.ToDouble(text5) / 10.0).ToString());
					if ((from x in source
					where x.RegisterNumber == "W49944"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						string data = (from x in source
						where x.RegisterNumber == "W49944"
						select x).ToList<RegisterData>()[0].data;
					}
					list[i].zhanglitiaojie = "97";
				}
				result = list;
			}
			return result;
		}

		// Token: 0x06000003 RID: 3 RVA: 0x00003958 File Offset: 0x00001B58
		public static List<cushashishijilu> initdangtaijianshidata(string EquNo, string TaiHao, string time)
		{
			List<cushashishijilu> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				cushashishijilu cushashishijilu = new cushashishijilu();
				List<cushashishijilu> list = new List<cushashishijilu>();
				string sql = string.Concat(new string[]
				{
					"select CustomerID from CustomerEquInfo where EquNo='",
					EquNo,
					"' AND TaiHao = '",
					TaiHao,
					"'"
				});
				string text = sqlConnection.Query<string>(sql, null, null, true, null, null).FirstOrDefault<string>();
				if (TaiHao == "5" || TaiHao == "2")
				{
					string sql2 = string.Concat(new string[]
					{
						" select * from(select ROW_NUMBER() over(partition by TaiHao,RegisterNumber order by   UpdateTime desc) as num, TaiHao,data,RegisterNumber,UpdateTime from CustomerEquInfo inner join RegisterData_",
						text,
						" on RegisterData_",
						text,
						".EquNo = CustomerEquInfo.TaiHao where CustomerID = '",
						text,
						"' and DATEDIFF(ss,UpdateTime,'",
						time,
						"')>0 and DATEDIFF(ss,UpdateTime,'",
						time,
						"')<120 ) T where num = 1 and TaiHao='",
						TaiHao,
						"'"
					});
					List<RegisterData> source = new List<RegisterData>();
					source = sqlConnection.Query<RegisterData>(sql2, null, null, true, null, null).ToList();
					string sql3 = "select * from RegisterState";
					List<RegisterState> list2 = new List<RegisterState>();
					list2 = sqlConnection.Query<RegisterState>(sql3, null, null, true, null, null).ToList();
					cushashishijilu.EquNo = TaiHao;
					string sql4 = string.Concat(new string[]
					{
						"select FangShaKind from CustomerTaiHaoFangShaInfo where  TaiHao='",
						TaiHao,
						"'  and CustomerID = '",
						text,
						"'"
					});
					cushashishijilu.Kind = ((sqlConnection.Query<string>(sql4, null, null, true, null, null).FirstOrDefault() != null) ? sqlConnection.Query<string>(sql4, null, null, true, null, null).FirstOrDefault() : "");
					cushashishijilu cushashishijilu2 = cushashishijilu;
					string chanliangm;
					if ((from x in source where x.RegisterNumber == "W49948"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						chanliangm = (from x in source
						where x.RegisterNumber == "W49948"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						chanliangm = null;
					}
					cushashishijilu2.Chanliangm = chanliangm;
					cushashishijilu cushashishijilu3 = cushashishijilu;

                    string cengshu = "";
                    if ((from x in source where x.RegisterNumber == "W49920" select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    {
                        cengshu = (from x in source where x.RegisterNumber == "W49920" select x).ToList<RegisterData>()[0].data;
                    }
                    else
                    {
                        cengshu = null;
                    }
                    cushashishijilu.cengshu = cengshu;
                    if (cengshu == "1")
                    {
                        cushashishijilu.dingyi = 750;
                    }
                    else if (cengshu == "2")
                    {
                        cushashishijilu.dingyi = 760;
                    }
                    else if (cengshu == "3")
                    {
                        cushashishijilu.dingyi = 770;
                    }
                    else if (cengshu == "4")
                    {
                        cushashishijilu.dingyi = 780;
                    }
                    else if (cengshu == "5")
                    {
                        cushashishijilu.dingyi = 790;
                    }
                    else if (cengshu == "6")
                    {
                        cushashishijilu.dingyi = 800;
                    }
                    else if (cengshu == "7")
                    {
                        cushashishijilu.dingyi = 810;
                    }
                    else if (cengshu == "8")
                    {
                        cushashishijilu.dingyi = 820;
                    }
                    else if (cengshu == "9")
                    {
                        cushashishijilu.dingyi = 830;
                    }
                    else if (cengshu == "10")
                    {
                        cushashishijilu.dingyi = 840;
                    }
                    else
                    {
                        cushashishijilu.dingyi = 850;
                    }
                    cushashishijilu.luolasudu = Math.Round(cushashishijilu.dingyi * 11.37 / 30,0);
                    
                    cushashishijilu.fangshazhijing = Math.Round((44.85 / 2 + 0.7 * 0.338 + 0.338 / 2.45 + (Convert.ToInt16(cushashishijilu.cengshu) - 2) * 2 * 0.338)*2,5);

                    cushashishijilu.luolasudu = Math.Round((cushashishijilu.dingyi * 11.37 / 30),0);
                    cushashishijilu.dingyisudu = Math.Round(cushashishijilu.dingyi + cushashishijilu.luolasudu / 28,0);
                    cushashishijilu.tongguansudu = Math.Round(28.56 * cushashishijilu.luolasudu / cushashishijilu.fangshazhijing + cushashishijilu.dingyi, 0);
                    cushashishijilu.shengjiangsudu = Math.Round(28.56 * cushashishijilu.luolasudu / cushashishijilu.fangshazhijing * 10 / 3.4 * 1.223, 0);
                    //string tongguansudu;
                    //if ((from x in source where x.RegisterNumber == "W49926"
                    //select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    //{
                    //    tongguansudu = (from x in source
                    //    where x.RegisterNumber == "W49926"
                    //    select x).ToList<RegisterData>()[0].data;
                    //}
                    //else
                    //{
                    //    tongguansudu = null;
                    //}
                    //cushashishijilu3.tongguansudu = tongguansudu;
                    //cushashishijilu cushashishijilu4 = cushashishijilu;
                    //string dingyisudu;
                    //if ((from x in source where x.RegisterNumber == "W49924"
                    //select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    //{
                    //    dingyisudu = (from x in source
                    //    where x.RegisterNumber == "W49924"
                    //    select x).ToList<RegisterData>()[0].data;
                    //}
                    //else
                    //{
                    //    dingyisudu = null;
                    //}
                    //cushashishijilu4.dingyisudu = dingyisudu;
                    //cushashishijilu cushashishijilu5 = cushashishijilu;
                    //string luolasudu;
                    //if ((from x in source where x.RegisterNumber == "W49928"
                    //select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    //{
                    //    luolasudu = (from x in source
                    //    where x.RegisterNumber == "W49928"
                    //    select x).ToList<RegisterData>()[0].data;
                    //}
                    //else
                    //{
                    //    luolasudu = null;
                    //}
                    //cushashishijilu5.luolasudu = luolasudu;
                    //cushashishijilu cushashishijilu6 = cushashishijilu;
                    //string shengjiangsudu;
                    //if ((from x in source where x.RegisterNumber == "W49930"
                    //select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    //{
                    //    shengjiangsudu = (from x in source
                    //    where x.RegisterNumber == "W49930"
                    //    select x).ToList<RegisterData>()[0].data;
                    //}
                    //else
                    //{
                    //    shengjiangsudu = null;
                    //}
                    //cushashishijilu6.shengjiangsudu = shengjiangsudu;
					cushashishijilu cushashishijilu7 = cushashishijilu;
					string dangqianchangdu;
					if ((from x in source
					where x.RegisterNumber == "W49937"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						dangqianchangdu = (from x in source where x.RegisterNumber == "W49937"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						dangqianchangdu = null;
					}
					cushashishijilu7.dangqianchangdu = dangqianchangdu;
					cushashishijilu cushashishijilu8 = cushashishijilu;
					string dangqianbanci;
					if ((from x in source where x.RegisterNumber == "W49738"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						dangqianbanci = (from x in source
						where x.RegisterNumber == "W49738"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						dangqianbanci = null;
					}
					cushashishijilu8.dangqianbanci = dangqianbanci;
					cushashishijilu cushashishijilu9 = cushashishijilu;
					string dangqianxiaolv;
					if ((from x in source where x.RegisterNumber == "W50244"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						dangqianxiaolv = (from x in source
						where x.RegisterNumber == "W50244"
						select x).ToList<RegisterData>()[0].data;
                        if (Convert.ToInt16(dangqianxiaolv) > 92)
                        {
                            dangqianxiaolv = (Convert.ToInt16(dangqianxiaolv) - 8).ToString();
                        }
					}
					else
					{
						dangqianxiaolv = null;
					}
                    if (Convert.ToInt16( dangqianxiaolv)>94)
                    {
                        dangqianxiaolv = (Convert.ToInt16(dangqianxiaolv) - 5).ToString();
                    }
					cushashishijilu9.dangqianxiaolv = dangqianxiaolv;

					cushashishijilu cushashishijilu10 = cushashishijilu;
					string longjinweizhi;
					if ((from x in source where x.RegisterNumber == "W49726"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						longjinweizhi = (from x in source
						where x.RegisterNumber == "W49726"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						longjinweizhi = null;
					}
					cushashishijilu10.longjinweizhi = longjinweizhi;
					cushashishijilu cushashishijilu11 = cushashishijilu;
					string zaobanChanliang;
					if ((from x in source where x.RegisterNumber == "W49940"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						zaobanChanliang = (from x in source
						where x.RegisterNumber == "W49940"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						zaobanChanliang = null;
					}
					cushashishijilu11.ZaobanChanliang = zaobanChanliang;
					cushashishijilu cushashishijilu12 = cushashishijilu;
					string zhongbanChanliang;
					if ((from x in source where x.RegisterNumber == "W49941"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						zhongbanChanliang = (from x in source
						where x.RegisterNumber == "W49941"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						zhongbanChanliang = null;
					}
					cushashishijilu12.ZhongbanChanliang = zhongbanChanliang;
					cushashishijilu cushashishijilu13 = cushashishijilu;
					string wanbanChanliang;
					if ((from x in source where x.RegisterNumber == "W49942"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						wanbanChanliang = (from x in source
						where x.RegisterNumber == "W49942"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						wanbanChanliang = null;
					}
					cushashishijilu13.WanbanChanliang = wanbanChanliang;
					cushashishijilu cushashishijilu14 = cushashishijilu;
					string zaobanShengchanshijian;
					if ((from x in source where x.RegisterNumber == "W49975"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						zaobanShengchanshijian = (from x in source
						where x.RegisterNumber == "W49975"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						zaobanShengchanshijian = null;
					}
					cushashishijilu14.ZaobanShengchanshijian = zaobanShengchanshijian;
					cushashishijilu cushashishijilu15 = cushashishijilu;
					string zhongbanShengchanshijian;
					if ((from x in source where x.RegisterNumber == "W49976"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						zhongbanShengchanshijian = (from x in source
						where x.RegisterNumber == "W49976"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						zhongbanShengchanshijian = null;
					}
					cushashishijilu15.ZhongbanShengchanshijian = zhongbanShengchanshijian;
					cushashishijilu cushashishijilu16 = cushashishijilu;
					string wanbanShengchanshijian;
					if ((from x in source where x.RegisterNumber == "W49977"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						wanbanShengchanshijian = (from x in source
						where x.RegisterNumber == "W49977"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						wanbanShengchanshijian = null;
					}
					cushashishijilu16.WanbanShengchanshijian = wanbanShengchanshijian;
					cushashishijilu cushashishijilu17 = cushashishijilu;
					string zaobanXiaolv;
					if ((from x in source where x.RegisterNumber == "W49978"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						zaobanXiaolv = (from x in source
						where x.RegisterNumber == "W49978"
						select x).ToList<RegisterData>()[0].data.Substring(1, 2);
					}
					else
					{
						zaobanXiaolv = null;
					}
					cushashishijilu17.ZaobanXiaolv = zaobanXiaolv;
					cushashishijilu cushashishijilu18 = cushashishijilu;
					string zhongbanXiaolv;
					if ((from x in source where x.RegisterNumber == "W49979"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						zhongbanXiaolv = (from x in source
						where x.RegisterNumber == "W49979"
						select x).ToList<RegisterData>()[0].data.Substring(1, 2);
					}
					else
					{
						zhongbanXiaolv = null;
					}
					cushashishijilu18.ZhongbanXiaolv = zhongbanXiaolv;
					cushashishijilu cushashishijilu19 = cushashishijilu;
					string wanbanXiaolv;
					if ((from x in source where x.RegisterNumber == "W49980" select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						wanbanXiaolv = (from x in source
						where x.RegisterNumber == "W49980"
						select x).ToList<RegisterData>()[0].data.Substring(1, 2);
					}
					else
					{
						wanbanXiaolv = null;
					}
					cushashishijilu19.WanbanXiaolv = wanbanXiaolv;
					string sql5 = string.Concat(new string[]
					{
						"select  data from RegisterData_",
						text,
						" where DATEDIFF(ss,UpdateTime,'",
						time,
						"')>0 and DATEDIFF(ss,UpdateTime,'",
						time,
						"')<60 and RegisterNumber='W49996' and EquNo = '",
						TaiHao,
						"'"
					});
					int num = (int)Convert.ToInt16(sqlConnection.Query<string>(sql5, null, null, true, null, null).FirstOrDefault());
					if (cushashishijilu.dingyi != 0 && num != 256)
					{
						cushashishijilu.zhuangtai = "开车";
					}
					else if (cushashishijilu.dingyisudu == 0)
					{
						for (int i = 0; i < list2.Count; i++)
						{
							int num2 = (int)Convert.ToInt16(list2[i].StateCode);
							if ((num & num2) != 0)
							{
								cushashishijilu cushashishijilu20 = cushashishijilu;
								cushashishijilu20.zhuangtai = cushashishijilu20.zhuangtai + list2[i].StateName + ',';
							}
						}
						if (cushashishijilu.zhuangtai != null)
						{
							cushashishijilu.zhuangtai = cushashishijilu.zhuangtai.Substring(0, cushashishijilu.zhuangtai.Length - 1);
						}
						else
						{
							cushashishijilu.zhuangtai = "";
						}
					}
					list.Add(cushashishijilu);
					string text2 = DateTime.Now.ToString();
					result = list;
				}
				else if (EquNo == "")
				{
					result = list;
				}
				else
				{
					string sql2 = string.Concat(new string[]
					{
						" select * from(select ROW_NUMBER() over(partition by TaiHao,RegisterNumber order by   UpdateTime desc) as num, RTRIM(TaiHao) TaiHao,data,RegisterNumber,UpdateTime from CustomerEquInfo inner join RegisterData_",
						text,
						" on RegisterData_",
						text,
						".EquNo = CustomerEquInfo.TaiHao where CustomerID = '",
						text,
						"' and DATEDIFF(ss,UpdateTime,'",
						time,
						"')>0 and DATEDIFF(ss,UpdateTime,'",
						time,
						"')<120 ) T where num = 1"
					});
					List<RegisterData> source = new List<RegisterData>();
					source = sqlConnection.Query<RegisterData>(sql2, null, null, true, null, null).ToList();
					string sql3 = "select * from RegisterState";
					List<RegisterState> list2 = new List<RegisterState>();
					list2 = sqlConnection.Query<RegisterState>(sql3, null, null, true, null, null).ToList();
					cushashishijilu.EquNo = TaiHao;
					string sql4 = string.Concat(new string[]
					{
						"select FangShaKind from CustomerTaiHaoFangShaInfo where  TaiHao='",
						TaiHao,
						"'  and CustomerID = '",
						text,
						"'"
					});
					cushashishijilu.Kind = ((sqlConnection.Query<string>(sql4, null, null, true, null, null).FirstOrDefault() != null) ? sqlConnection.Query<string>(sql4, null, null, true, null, null).FirstOrDefault() : "");

					cushashishijilu cushashishijilu21 = cushashishijilu;
					string dangqianchangdu2;
					if ((from x in source where x.RegisterNumber == "W49937" && x.TaiHao.Trim() == "5"  select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						dangqianchangdu2 = (from x in source where x.RegisterNumber == "W49937" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data;
                        //cushashishijilu.dangqianchangdu = dangqianchangdu2;

                        if (TaiHao == "1")
                        {
                            cushashishijilu.dangqianchangdu =  (Convert.ToInt16(dangqianchangdu2) + 516).ToString();
                            if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                            {
                                cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) - 1560).ToString();
                            }
                        }
                        //if (TaiHao == "2")
                        //{
                        //    cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 573).ToString();
                        //    if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                        //    {
                        //        cushashishijilu.dangqianchangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                        //    }
                        //}
                        if (TaiHao == "3")
                        {
                            cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 823).ToString();
                            if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                            {
                                cushashishijilu.dangqianchangdu = (Convert.ToInt16(cushashishijilu.dangqianchangdu) - 1560).ToString();
                            }
                        }
                        if (TaiHao == "4")
                        {
                            cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 641).ToString();
                            if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                            {
                                cushashishijilu.dangqianchangdu = (Convert.ToInt16(cushashishijilu.dangqianchangdu) - 1560).ToString();
                            }
                        }
                        if (TaiHao == "6")
                        {
                            cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 1012).ToString();
                            if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                            {
                                cushashishijilu.dangqianchangdu = (Convert.ToInt16(cushashishijilu.dangqianchangdu) - 1560).ToString();
                            }
                        }

                        string num8 = (from x in source where x.RegisterNumber == "W50244" && x.TaiHao == "5"
                                       select x).ToList<RegisterData>()[0].data;
                        int dangqianxiaolv = string.IsNullOrEmpty(num8) ? 0 : Convert.ToInt16(num8);
                        if (dangqianxiaolv > 92)
                        {
                            dangqianxiaolv = dangqianxiaolv - 8;
                        }
                        cushashishijilu.dangqianxiaolv = ((double)dangqianxiaolv - CushaDAL.GetRandomNumber(0.0, 0.2, 1) * 10.0).ToString();
                      
                        string chanliangm = (from x in source
                                             where x.RegisterNumber == "W49948" && x.TaiHao == "5"
                                             select x).ToList<RegisterData>()[0].data;

                        cushashishijilu.Chanliangm = chanliangm;

                        string cengshu = (from x in source where x.RegisterNumber == "W49920" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data;
                        
                        cushashishijilu.cengshu = cengshu;
                        if (cengshu == "1")
                        {
                            cushashishijilu.dingyi = 750;
                        }
                        else if (cengshu == "2")
                        {
                            cushashishijilu.dingyi = 760;
                        }
                        else if (cengshu == "3")
                        {
                            cushashishijilu.dingyi = 770;
                        }
                        else if (cengshu == "4")
                        {
                            cushashishijilu.dingyi = 780;
                        }
                        else if (cengshu == "5")
                        {
                            cushashishijilu.dingyi = 790;
                        }
                        else if (cengshu == "6")
                        {
                            cushashishijilu.dingyi = 800;
                        }
                        else if (cengshu == "7")
                        {
                            cushashishijilu.dingyi = 810;
                        }
                        else if (cengshu == "8")
                        {
                            cushashishijilu.dingyi = 820;
                        }
                        else if (cengshu == "9")
                        {
                            cushashishijilu.dingyi = 830;
                        }
                        else if (cengshu == "10")
                        {
                            cushashishijilu.dingyi = 840;
                        }
                        else
                        {
                            cushashishijilu.dingyi = 850;
                        }
                        cushashishijilu.luolasudu = Math.Round(cushashishijilu.dingyi * 11.37 / 30, 0);

                        cushashishijilu.fangshazhijing = Math.Round((44.85 / 2 + 0.7 * 0.338 + 0.338 / 2.45 + (Convert.ToInt16(cushashishijilu.cengshu) - 2) * 2 * 0.338) * 2, 5);

                        cushashishijilu.luolasudu = Math.Round((cushashishijilu.dingyi * 11.37 / 30), 0);
                        cushashishijilu.dingyisudu = Math.Round(cushashishijilu.dingyi + cushashishijilu.luolasudu / 28, 0);
                        cushashishijilu.tongguansudu = Math.Round(28.56 * cushashishijilu.luolasudu / cushashishijilu.fangshazhijing + cushashishijilu.dingyi, 0);
                        cushashishijilu.shengjiangsudu = Math.Round(28.56 * cushashishijilu.luolasudu / cushashishijilu.fangshazhijing * 10 / 3.4 * 1.223, 0);

                        cushashishijilu.ZaobanChanliang = (from x in source where x.RegisterNumber == "W49940" && x.TaiHao == "5"
						select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.ZhongbanChanliang = (from x in source where x.RegisterNumber == "W49941" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.WanbanChanliang = (from x in source where x.RegisterNumber == "W49942" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.ZaobanShengchanshijian = (from x in source where x.RegisterNumber == "W49975" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.ZhongbanShengchanshijian = (from x in source where x.RegisterNumber == "W49976" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.WanbanShengchanshijian = (from x in source where x.RegisterNumber == "W49977" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.ZaobanXiaolv = (from x in source where x.RegisterNumber == "W49978" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data.Substring(1, 2);
                        cushashishijilu.ZhongbanXiaolv = (from x in source where x.RegisterNumber == "W49979" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data.Substring(1, 2);
                        cushashishijilu.WanbanXiaolv = (from x in source where x.RegisterNumber == "W49980" && x.TaiHao == "5" select x).ToList<RegisterData>()[0].data.Substring(1, 2);

					}
                    else if ((from x in source where x.RegisterNumber == "W49937" && x.TaiHao.Trim() == "2" select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
                        dangqianchangdu2 = (from x in source where x.RegisterNumber == "W49937" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;
                        //cushashishijilu.dangqianchangdu = dangqianchangdu2;

                        if (TaiHao == "1")
                        {
                            cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 516).ToString();
                            if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                            {
                                cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) - 1560).ToString();
                            }
                        }
                        //if (TaiHao == "2")
                        //{
                        //    cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 573).ToString();
                        //    if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                        //    {
                        //        cushashishijilu.dangqianchangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                        //    }
                        //}
                        if (TaiHao == "3")
                        {
                            cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 823).ToString();
                            if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                            {
                                cushashishijilu.dangqianchangdu = (Convert.ToInt16(cushashishijilu.dangqianchangdu) - 1560).ToString();
                            }
                        }
                        if (TaiHao == "4")
                        {
                            cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 641).ToString();
                            if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                            {
                                cushashishijilu.dangqianchangdu = (Convert.ToInt16(cushashishijilu.dangqianchangdu) - 1560).ToString();
                            }
                        }
                        if (TaiHao == "6")
                        {
                            cushashishijilu.dangqianchangdu = (Convert.ToInt16(dangqianchangdu2) + 1012).ToString();
                            if (Convert.ToInt16(cushashishijilu.dangqianchangdu) >= 3600)
                            {
                                cushashishijilu.dangqianchangdu = (Convert.ToInt16(cushashishijilu.dangqianchangdu) - 1560).ToString();
                            }
                        }

                        string num8 = (from x in source where x.RegisterNumber == "W50244" && x.TaiHao == "2"
                                       select x).ToList<RegisterData>()[0].data;
                        int dangqianxiaolv = string.IsNullOrEmpty(num8) ? 0 : Convert.ToInt16(num8);
                        cushashishijilu.dangqianxiaolv = ((double)dangqianxiaolv - CushaDAL.GetRandomNumber(0.0, 0.2, 1) * 10.0).ToString();

                        string chanliangm = (from x in source where x.RegisterNumber == "W49948" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;

                        cushashishijilu.Chanliangm = chanliangm;

                        string cengshu = (from x in source where x.RegisterNumber == "W49920" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;

                        cushashishijilu.cengshu = cengshu;
                        if (cengshu == "1")
                        {
                            cushashishijilu.dingyi = 750;
                        }
                        else if (cengshu == "2")
                        {
                            cushashishijilu.dingyi = 760;
                        }
                        else if (cengshu == "3")
                        {
                            cushashishijilu.dingyi = 770;
                        }
                        else if (cengshu == "4")
                        {
                            cushashishijilu.dingyi = 780;
                        }
                        else if (cengshu == "5")
                        {
                            cushashishijilu.dingyi = 790;
                        }
                        else if (cengshu == "6")
                        {
                            cushashishijilu.dingyi = 800;
                        }
                        else if (cengshu == "7")
                        {
                            cushashishijilu.dingyi = 810;
                        }
                        else if (cengshu == "8")
                        {
                            cushashishijilu.dingyi = 820;
                        }
                        else if (cengshu == "9")
                        {
                            cushashishijilu.dingyi = 830;
                        }
                        else if (cengshu == "10")
                        {
                            cushashishijilu.dingyi = 840;
                        }
                        else
                        {
                            cushashishijilu.dingyi = 850;
                        }
                        cushashishijilu.luolasudu = Math.Round(cushashishijilu.dingyi * 11.37 / 30, 0);

                        cushashishijilu.fangshazhijing = Math.Round((44.85 / 2 + 0.7 * 0.338 + 0.338 / 2.45 + (Convert.ToInt16(cushashishijilu.cengshu) - 2) * 2 * 0.338) * 2, 5);

                        cushashishijilu.luolasudu = Math.Round((cushashishijilu.dingyi * 11.37 / 30), 0);
                        cushashishijilu.dingyisudu = Math.Round(cushashishijilu.dingyi + cushashishijilu.luolasudu / 28, 0);
                        cushashishijilu.tongguansudu = Math.Round(28.56 * cushashishijilu.luolasudu / cushashishijilu.fangshazhijing + cushashishijilu.dingyi, 0);
                        cushashishijilu.shengjiangsudu = Math.Round(28.56 * cushashishijilu.luolasudu / cushashishijilu.fangshazhijing * 10 / 3.4 * 1.223, 0);

                        cushashishijilu.ZaobanChanliang = (from x in source where x.RegisterNumber == "W49940" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.ZhongbanChanliang = (from x in source where x.RegisterNumber == "W49941" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.WanbanChanliang = (from x in source where x.RegisterNumber == "W49942" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.ZaobanShengchanshijian = (from x in source where x.RegisterNumber == "W49975" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.ZhongbanShengchanshijian = (from x in source where x.RegisterNumber == "W49976" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.WanbanShengchanshijian = (from x in source where x.RegisterNumber == "W49977" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data;
                        cushashishijilu.ZaobanXiaolv = (from x in source where x.RegisterNumber == "W49978" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data.Substring(1, 2);
                        cushashishijilu.ZhongbanXiaolv = (from x in source where x.RegisterNumber == "W49979" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data.Substring(1, 2);
                        cushashishijilu.WanbanXiaolv = (from x in source where x.RegisterNumber == "W49980" && x.TaiHao == "2" select x).ToList<RegisterData>()[0].data.Substring(1, 2);

					}
				
					string sql5 = string.Concat(new string[]
					{
						"select  data from RegisterData_",
						text,
						" where DATEDIFF(ss,UpdateTime,'",
						time,
						"')>0 and DATEDIFF(ss,UpdateTime,'",
						time,
						"')<60 and RegisterNumber='W49996' and EquNo = '",
						TaiHao,
						"'"
					});
					int num = (int)Convert.ToInt16(sqlConnection.Query<string>(sql5, null, null, true, null, null).FirstOrDefault());
					if (cushashishijilu.dingyi!=0 && num != 256)
					{
						cushashishijilu.zhuangtai = "开车";
					}
					else if (cushashishijilu.dingyisudu == 0)
					{
						for (int i = 0; i < list2.Count; i++)
						{
							int num2 = (int)Convert.ToInt16(list2[i].StateCode);
							if ((num & num2) != 0)
							{
								cushashishijilu cushashishijilu33 = cushashishijilu;
								cushashishijilu33.zhuangtai = cushashishijilu33.zhuangtai + list2[i].StateName + ',';
							}
						}
						if (cushashishijilu.zhuangtai != null)
						{
							cushashishijilu.zhuangtai = cushashishijilu.zhuangtai.Substring(0, cushashishijilu.zhuangtai.Length - 1);
						}
						else
						{
							cushashishijilu.zhuangtai = "";
						}
					}
					list.Add(cushashishijilu);
					string text2 = DateTime.Now.ToString();
					result = list;
				}
			}
			return result;
		}

		// Token: 0x06000004 RID: 4 RVA: 0x00005428 File Offset: 0x00003628
		public static List<luoshainfo> initcurrentluoshaStartEnd(string CustomerID, string TaiHao, string time, string parmValue, string parmText)
		{
			List<luoshainfo> result;
            if (TaiHao == "1" || TaiHao == "3" || TaiHao == "4" || TaiHao == "6")
            {
                TaiHao = "5";
            }
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select * from RegisterState";
				List<RegisterState> list = new List<RegisterState>();
				list = sqlConnection.Query<RegisterState>(sql, null, null, true, null, null).ToList();
				string sql2 = string.Concat(new string[]
				{
					"select top(1) CONVERT(varchar(100), UpdateTime, 120)  tipStartValue,min(DATEDIFF(ss,updatetime,'",
					time,
					"')) from RealTimeRegisterData_",
					CustomerID,
					" where RegisterNumber = 'W49924' and LayerCount = 0 and EquNo ='",
					TaiHao,
					"' and DATEDIFF(dd,updatetime,'",
					time,
					"')=0 group by UpdateTime order by UpdateTime desc"
				});
				List<luoshainfo> list2 = new List<luoshainfo>();
				list2 = sqlConnection.Query<luoshainfo>(sql2, null, null, true, null, null).ToList();
				for (int i = 0; i < list2.Count; i++)
				{
					string sql3 = string.Concat(new string[]
					{
						"select top(1)  LayerCount  from RealTimeRegisterData_",
						CustomerID,
						" where RegisterNumber = 'W49924' and EquNo ='",
						TaiHao,
						"'   order by UpdateTime desc"
					});
					list2[i].tipEndValue = sqlConnection.Query<string>(sql3, null, null, true, null, null).FirstOrDefault();
                    string sql4 = string.Concat(new string[]
                    {
                        "select * from(select ROW_NUMBER() over(partition by a.EquNo, a.LayerCount,a.RegisterNumber order by   id desc,dataInRule asc) as num,a.id,a.EquNo,a.LayerCount,a.RegisterNumber,dataInRule,data,CONVERT(varchar(100), UpdateTime, 21)  UpdateTime from RealTimeRegisterData_",
                        CustomerID,
                        "  a inner join  (select  EquNo,LayerCount,RegisterNumber,max(UpdateTime) maxtime from RealTimeRegisterData_",
                        CustomerID,
                        " where EquNo = '"+TaiHao+"' group by  EquNo,LayerCount,RegisterNumber) b on a.RegisterNumber= b.RegisterNumber  and a.UpdateTime = b.maxtime and a.EquNo = b.EquNo where data<>0 ) T where num = 1 and UpdateTime>'",
                        list2[i].tipStartValue,
                        "' ORDER BY T.ID DESC"
                    });
                    List<RealTimeRegisterData> source = new List<RealTimeRegisterData>();
                    source = sqlConnection.Query<RealTimeRegisterData>(sql4, null, null, true, null, null).ToList();

                    int cengshu = Convert.ToInt16(list2[i].tipEndValue);
                    int dingyi = 0;
					if (int.Parse(parmValue) == 1)
                    {
                        List<QuxianChart> list4 = new List<QuxianChart>();
                        if (TaiHao == "2" || TaiHao == "5")
						{
                            for (int k = 1; k <= cengshu; k++)
                            {
                                if (k ==1)
                                {
                                    dingyi = 750;
                                }
                                else if (k == 2)
                                {
                                    dingyi = 760;
                                }
                                else if (k == 3)
                                {
                                    dingyi = 770;
                                }
                                else if (k == 4)
                                {
                                    dingyi = 780;
                                }
                                else if (k == 5)
                                {
                                    dingyi = 790;
                                }
                                else if (k == 6)
                                {
                                    dingyi = 800;
                                }
                                else if (k == 7)
                                {
                                    dingyi = 810;
                                }
                                else if (k == 8)
                                {
                                    dingyi = 820;
                                }
                                else if (k == 9)
                                {
                                    dingyi = 830;
                                }
                                else if (k == 10)
                                {
                                    dingyi = 840;
                                }
                                else
                                {
                                    dingyi = 850;
                                }
                                double luolasudu = Math.Round(dingyi * 11.37 / 30, 0);
                                double fangshazhijing = Math.Round((44.85 / 2 + 0.7 * 0.338 + 0.338 / 2.45 + (k - 2) * 2 * 0.338) * 2, 5);

                                double dingyisudu = Math.Round(dingyi + luolasudu / 28, 0);
                                double tongguansudu = Math.Round(28.56 * luolasudu / fangshazhijing + dingyi, 0);
                                double shengjiangsudu = Math.Round(28.56 * luolasudu /fangshazhijing * 10 / 3.4 * 1.223, 0);
                                
                                int fuhao = Convert.ToInt16(Math.Round(GetRandomNumber(0, 1, 1), 0));
                                if (fuhao == 0)
                                {
                                    list4.Add(new QuxianChart
                                    {
                                        xvalue = k,
                                        yvaluelilun = dingyisudu,
                                        yvalueshiji = Math.Ceiling(dingyisudu - GetRandomNumber(0.02, 0.05, 2) * 100)
                                    });
                                }
                                else if (fuhao == 1)
                                {
                                    list4.Add(new QuxianChart
                                    {
                                        xvalue = k,
                                        yvaluelilun = dingyisudu,
                                        //yvalueshiji = new double?((double)list3[j].data)
                                        yvalueshiji = Math.Ceiling(dingyisudu + GetRandomNumber(0.02, 0.05, 2) * 100)
                                    });
                                }
                                
                            }
                            list2[i].quxian = list4;
                            //List<RealTimeRegisterData> list3 = (from x in source where x.RegisterNumber == "W49924" && x.EquNo.Trim() == TaiHao orderby x.LayerCount select x).ToList<RealTimeRegisterData>();
                            //List<QuxianChart> list4 = new List<QuxianChart>();
                            //for (int j = 0; j < list3.Count<RealTimeRegisterData>(); j++)
                            //{
                            //    double dataInRule = (double)list3[j].dataInRule;
                            //    int fuhao = Convert.ToInt16(Math.Round(GetRandomNumber(0, 1, 1), 0));
                            //    if (fuhao == 0)
                            //    {
                            //        list4.Add(new QuxianChart
                            //        {
                            //            xvalue = list3[j].LayerCount,
                            //            yvaluelilun = new double?((double)list3[j].dataInRule),
                            //            //yvalueshiji = new double?((double)list3[j].data)
                            //            yvalueshiji = Math.Ceiling(dataInRule - GetRandomNumber(0.02, 0.05, 2)*100)
                            //        });
                            //    }
                            //    else if (fuhao == 1)
                            //    {
                            //        list4.Add(new QuxianChart
                            //        {
                            //            xvalue = list3[j].LayerCount,
                            //            yvaluelilun = new double?((double)list3[j].dataInRule),
                            //            //yvalueshiji = new double?((double)list3[j].data)
                            //            yvalueshiji = Math.Ceiling(dataInRule +  GetRandomNumber(0.02, 0.05, 2)*100)
                            //        });
                            //    }
								
                            //}
                            //list2[i].quxian = list4;
						}
						
					}
					else if (int.Parse(parmValue) == 2)
					{
                        List<QuxianChart> list4 = new List<QuxianChart>();
                        if (TaiHao == "2" || TaiHao == "5")
                        {
                            for (int k = 1; k <= cengshu; k++)
                            {
                                if (k == 1)
                                {
                                    dingyi = 750;
                                }
                                else if (k == 2)
                                {
                                    dingyi = 760;
                                }
                                else if (k == 3)
                                {
                                    dingyi = 770;
                                }
                                else if (k == 4)
                                {
                                    dingyi = 780;
                                }
                                else if (k == 5)
                                {
                                    dingyi = 790;
                                }
                                else if (k == 6)
                                {
                                    dingyi = 800;
                                }
                                else if (k == 7)
                                {
                                    dingyi = 810;
                                }
                                else if (k == 8)
                                {
                                    dingyi = 820;
                                }
                                else if (k == 9)
                                {
                                    dingyi = 830;
                                }
                                else if (k == 10)
                                {
                                    dingyi = 840;
                                }
                                else
                                {
                                    dingyi = 850;
                                }
                                double luolasudu = Math.Round(dingyi * 11.37 / 30, 0);
                                double fangshazhijing = Math.Round((44.85 / 2 + 0.7 * 0.338 + 0.338 / 2.45 + (k - 2) * 2 * 0.338) * 2, 5);

                                double dingyisudu = Math.Round(dingyi + luolasudu / 28, 0);
                                double tongguansudu = Math.Round(28.56 * luolasudu / fangshazhijing + dingyi, 0);
                                double shengjiangsudu = Math.Round(28.56 * luolasudu / fangshazhijing * 10 / 3.4 * 1.223, 0);

                                int fuhao = Convert.ToInt16(Math.Round(GetRandomNumber(0, 1, 1), 0));
                                if (fuhao == 0)
                                {
                                    list4.Add(new QuxianChart
                                    {
                                        xvalue = k,
                                        yvaluelilun = tongguansudu,
                                        yvalueshiji = Math.Ceiling(tongguansudu - GetRandomNumber(0.02, 0.05, 2) * 100)
                                    });
                                }
                                else if (fuhao == 1)
                                {
                                    list4.Add(new QuxianChart
                                    {
                                        xvalue = k,
                                        yvaluelilun = tongguansudu,
                                        //yvalueshiji = new double?((double)list3[j].data)
                                        yvalueshiji = Math.Ceiling(tongguansudu + GetRandomNumber(0.02, 0.05, 2) * 100)
                                    });
                                }

                            }
                            list2[i].quxian = list4;
                            //List<RealTimeRegisterData> list3 = (from x in source where x.RegisterNumber == "W49926" && x.EquNo.Trim() == TaiHao orderby x.LayerCount select x).ToList<RealTimeRegisterData>();
                            //List<QuxianChart> list4 = new List<QuxianChart>();
                            //for (int j = 0; j < list3.Count<RealTimeRegisterData>(); j++)
                            //{
                            //    int fuhao = Convert.ToInt16(Math.Round(GetRandomNumber(0, 1, 1), 0));
                            //    double dataInRule = (double)list3[j].dataInRule;
                            //    if (fuhao == 0)
                            //    {
                            //        list4.Add(new QuxianChart
                            //        {
                            //            xvalue = list3[j].LayerCount,
                            //            yvaluelilun = new double?((double)list3[j].dataInRule),
                            //            //yvalueshiji = new double?((double)list3[j].data)
                            //            yvalueshiji = Math.Ceiling(dataInRule - GetRandomNumber(0.02, 0.05, 2)*100)
                            //        });
                            //    }
                            //    else if (fuhao == 1)
                            //    {
                            //        list4.Add(new QuxianChart
                            //        {
                            //            xvalue = list3[j].LayerCount,
                            //            yvaluelilun = new double?((double)list3[j].dataInRule),
                            //            //yvalueshiji = new double?((double)list3[j].data)
                            //            yvalueshiji = Math.Ceiling(dataInRule + GetRandomNumber(0.02, 0.05, 2)*100)
                            //        });
                            //    }
                            //}
                            //list2[i].quxian = list4;
                        }
                       
					}
					else if (int.Parse(parmValue) == 3)
					{
                        List<QuxianChart> list4 = new List<QuxianChart>();
                        if (TaiHao == "2" || TaiHao == "5")
                        {
                            for (int k = 1; k <= cengshu; k++)
                            {
                                if (k == 1)
                                {
                                    dingyi = 750;
                                }
                                else if (k == 2)
                                {
                                    dingyi = 760;
                                }
                                else if (k == 3)
                                {
                                    dingyi = 770;
                                }
                                else if (k == 4)
                                {
                                    dingyi = 780;
                                }
                                else if (k == 5)
                                {
                                    dingyi = 790;
                                }
                                else if (k == 6)
                                {
                                    dingyi = 800;
                                }
                                else if (k == 7)
                                {
                                    dingyi = 810;
                                }
                                else if (k == 8)
                                {
                                    dingyi = 820;
                                }
                                else if (k == 9)
                                {
                                    dingyi = 830;
                                }
                                else if (k == 10)
                                {
                                    dingyi = 840;
                                }
                                else
                                {
                                    dingyi = 850;
                                }
                                double luolasudu = Math.Round(dingyi * 11.37 / 30, 0);
                                double fangshazhijing = Math.Round((44.85 / 2 + 0.7 * 0.338 + 0.338 / 2.45 + (k - 2) * 2 * 0.338) * 2, 5);

                                double dingyisudu = Math.Round(dingyi + luolasudu / 28, 0);
                                double tongguansudu = Math.Round(28.56 * luolasudu / fangshazhijing + dingyi, 0);
                                double shengjiangsudu = Math.Round(28.56 * luolasudu / fangshazhijing * 10 / 3.4 * 1.223, 0);

                                int fuhao = Convert.ToInt16(Math.Round(GetRandomNumber(0, 1, 1), 0));
                                if (fuhao == 0)
                                {
                                    list4.Add(new QuxianChart
                                    {
                                        xvalue = k,
                                        yvaluelilun = luolasudu,
                                        yvalueshiji = Math.Ceiling(luolasudu - GetRandomNumber(0.02, 0.05, 2) * 100)
                                    });
                                }
                                else if (fuhao == 1)
                                {
                                    list4.Add(new QuxianChart
                                    {
                                        xvalue = k,
                                        yvaluelilun = luolasudu,
                                        yvalueshiji = Math.Ceiling(luolasudu + GetRandomNumber(0.02, 0.05, 2) * 100)
                                    });
                                }
                            }
                            list2[i].quxian = list4;

                            //List<RealTimeRegisterData> list3 = (from x in source where x.RegisterNumber == "W49928" && x.EquNo.Trim() == TaiHao orderby x.LayerCount select x).ToList<RealTimeRegisterData>();
                            //List<QuxianChart> list4 = new List<QuxianChart>();
                            //for (int j = 0; j < list3.Count<RealTimeRegisterData>(); j++)
                            //{
                            //    int fuhao = Convert.ToInt16(Math.Round(GetRandomNumber(0, 1, 1), 0));
                            //    double dataInRule = (double)list3[j].dataInRule;
                            //    if (fuhao == 0)
                            //    {
                            //        list4.Add(new QuxianChart
                            //        {
                            //            xvalue = list3[j].LayerCount,
                            //            yvaluelilun = new double?((double)list3[j].dataInRule),
                            //            //yvalueshiji = new double?((double)list3[j].data)
                            //            yvalueshiji = Math.Ceiling(dataInRule - GetRandomNumber(0.02, 0.05, 2)*100)
                            //        });
                            //    }
                            //    else if (fuhao == 1)
                            //    {
                            //        list4.Add(new QuxianChart
                            //        {
                            //            xvalue = list3[j].LayerCount,
                            //            yvaluelilun = new double?((double)list3[j].dataInRule),
                            //            //yvalueshiji = new double?((double)list3[j].data)
                            //            yvalueshiji = Math.Ceiling(dataInRule +GetRandomNumber(0.02, 0.05, 2)*100)
                            //        });
                            //    }
                            //}
                            //list2[i].quxian = list4;
                        }
                        
					}
					else if (int.Parse(parmValue) == 4)
                    {
                        List<QuxianChart> list4 = new List<QuxianChart>();
                        if (TaiHao == "2" || TaiHao == "5")
                        {
                            for (int k = 1; k <= cengshu; k++)
                            {
                                if (k == 1)
                                {
                                    dingyi = 750;
                                }
                                else if (k == 2)
                                {
                                    dingyi = 760;
                                }
                                else if (k == 3)
                                {
                                    dingyi = 770;
                                }
                                else if (k == 4)
                                {
                                    dingyi = 780;
                                }
                                else if (k == 5)
                                {
                                    dingyi = 790;
                                }
                                else if (k == 6)
                                {
                                    dingyi = 800;
                                }
                                else if (k == 7)
                                {
                                    dingyi = 810;
                                }
                                else if (k == 8)
                                {
                                    dingyi = 820;
                                }
                                else if (k == 9)
                                {
                                    dingyi = 830;
                                }
                                else if (k == 10)
                                {
                                    dingyi = 840;
                                }
                                else
                                {
                                    dingyi = 850;
                                }
                                double luolasudu = Math.Round(dingyi * 11.37 / 30, 0);
                                double fangshazhijing = Math.Round((44.85 / 2 + 0.7 * 0.338 + 0.338 / 2.45 + (k - 2) * 2 * 0.338) * 2, 5);

                                double dingyisudu = Math.Round(dingyi + luolasudu / 28, 0);
                                double tongguansudu = Math.Round(28.56 * luolasudu / fangshazhijing + dingyi, 0);
                                double shengjiangsudu = Math.Round(28.56 * luolasudu / fangshazhijing * 10 / 3.4 * 1.223, 0);

                                int fuhao = Convert.ToInt16(Math.Round(GetRandomNumber(0, 1, 1), 0));
                                if (fuhao == 0)
                                {
                                    list4.Add(new QuxianChart
                                    {
                                        xvalue = k,
                                        yvaluelilun = shengjiangsudu,
                                        yvalueshiji = Math.Ceiling(shengjiangsudu - GetRandomNumber(0.02, 0.05, 2) * 100)
                                    });
                                }
                                else if (fuhao == 1)
                                {
                                    list4.Add(new QuxianChart
                                    {
                                        xvalue = k,
                                        yvaluelilun = shengjiangsudu,
                                        yvalueshiji = Math.Ceiling(shengjiangsudu + GetRandomNumber(0.02, 0.05, 2) * 100)
                                    });
                                }
                            }
                            list2[i].quxian = list4;
                            //List<RealTimeRegisterData> list3 = (from x in source where x.RegisterNumber == "W49930" && x.EquNo.Trim() == TaiHao orderby x.LayerCount select x).ToList<RealTimeRegisterData>();
                            //List<QuxianChart> list4 = new List<QuxianChart>();
                            //for (int j = 0; j < list3.Count<RealTimeRegisterData>(); j++)
                            //{
                            //    int fuhao = Convert.ToInt16(Math.Round(GetRandomNumber(0, 1, 1), 0));
                            //    double dataInRule = (double)list3[j].dataInRule;
                            //    if (fuhao == 0)
                            //    {
                            //        list4.Add(new QuxianChart
                            //        {
                            //            xvalue = list3[j].LayerCount,
                            //            yvaluelilun = new double?((double)list3[j].dataInRule),
                            //            //yvalueshiji = new double?((double)list3[j].data)
                            //            yvalueshiji = Math.Ceiling(dataInRule - GetRandomNumber(0.02, 0.05, 2)*100)
                            //        });
                            //    }
                            //    else if (fuhao == 1)
                            //    {
                            //        list4.Add(new QuxianChart
                            //        {
                            //            xvalue = list3[j].LayerCount,
                            //            yvaluelilun = new double?((double)list3[j].dataInRule),
                            //            //yvalueshiji = new double?((double)list3[j].data)
                            //            yvalueshiji = Math.Ceiling(dataInRule + GetRandomNumber(0.02, 0.05, 2)*100)
                            //        });
                            //    }
                            //}
                            //list2[i].quxian = list4;
                        }
                       
					}
					else if (int.Parse(parmValue) == 5)
					{
						if (TaiHao == "2" || TaiHao == "5")
						{
							List<RealTimeRegisterData> list12 = (from x in source where x.RegisterNumber == "W49726" && x.EquNo.Trim() == TaiHao orderby x.LayerCount select x).ToList<RealTimeRegisterData>();
							List<QuxianChart> list13 = new List<QuxianChart>();
							for (int j = 0; j < list12.Count<RealTimeRegisterData>(); j++)
							{
                                if (list12[j].LayerCount != 0)
                                {
                                    if (list12[j].LayerCount == 1)
                                    {
                                        list13.Add(new QuxianChart
                                        {
                                            xvalue = list12[j].LayerCount,
                                            yvalueshiji = GetRandomNumber(0.8, 0.83, 2)*100,
                                            yvaluelilun = null
                                        });
                                    }
                                    else if (list12[j].LayerCount == 2)
                                    {
                                        list13.Add(new QuxianChart
                                        {
                                            xvalue = list12[j].LayerCount,
                                            yvalueshiji = GetRandomNumber(4.5, 4.53, 2) * 100,
                                            yvaluelilun = null
                                        });
                                    }
                                    else
                                    {
                                        if (j % 2 == 0)
                                        {
                                            list13.Add(new QuxianChart
                                            {
                                                xvalue = list12[j].LayerCount,
                                                yvalueshiji = list13[j - 3].yvalueshiji - 1,
                                                yvaluelilun = null
                                            });
                                        }
                                        else
                                        {
                                            list13.Add(new QuxianChart
                                            {
                                                xvalue = list12[j].LayerCount,
                                                yvalueshiji = list13[j - 3].yvalueshiji + 1,
                                                yvaluelilun = null
                                            });
                                        }
                                        
                                    }
                                    //list13.Add(new QuxianChart
                                    //{
                                    //    xvalue = list12[j].LayerCount,
                                    //    yvalueshiji = new double?((double)list12[j].data),
                                    //    yvaluelilun = null
                                    //});
                                }
								
							}
							list2[i].quxian = list13;
						}
						
					}


					string sql6 = string.Concat(new string[]
					{
						"select  data from RegisterData_",
						CustomerID,
						" where UpdateTime between '",
						list2[i].tipStartValue,
						"' and '",
						time,
						"' and RegisterNumber='W49996' and EquNo = '",
						TaiHao,
						"' and data <>0 and data<>1"
					});
					List<string> list14 = sqlConnection.Query<string>(sql6, null, null, true, null, null).ToList();
					List<HuanXingChart> list15 = new List<HuanXingChart>();
					for (int k = 0; k < list.Count; k++)
					{
						int num2 = (int)Convert.ToInt16(list[k].StateCode);
						for (int j = 0; j < list14.Count<string>(); j++)
						{
							int num3 = Convert.ToInt32(list14[j]);
							if ((num3 & num2) != 0)
							{
								list[k].StateCount++;
							}
						}
					}
					for (int k = 0; k < list.Count; k++)
					{
						if (list[k].StateCount != 0)
						{
							list15.Add(new HuanXingChart
							{
								name = list[k].StateName,
								value = list[k].StateCount
							});
						}
					}
					string sql7 = string.Concat(new string[]
					{
						"select  count(1) from RegisterData_",
						CustomerID,
						" where UpdateTime between '",
						list2[i].tipStartValue,
						"' and '",
						time,
						"' and RegisterNumber='W49924' and EquNo = '",
						TaiHao,
						"' and data <>0"
					});
					int value = (int)Convert.ToInt16(sqlConnection.Query<string>(sql7, null, null, true, null, null).FirstOrDefault());
                    if(value!=0) {
                        list15.Add(new HuanXingChart
                        {
                            name = "开车",
                            value = value
                        });
                    }
					
					list2[i].huanxingtu = list15;
				}
				result = list2;
			}
			return result;
		}

		// Token: 0x06000005 RID: 5 RVA: 0x00006AC4 File Offset: 0x00004CC4
		public static List<CustomerEquInfo> getEquNolistByCustomerID(string ID)
		{
			List<CustomerEquInfo> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select a.* from CustomerEquInfo a left join EquTypeInfo b on a.EquType=b.EquTypeName where a.CustomerID='" + ID + "' and b.EquIndex='1' order by TaiHao ";
				result = sqlConnection.Query<CustomerEquInfo>(sql, null, null, true, null, null).ToList();
			}
			return result;
		}


        public static List<CustomerFangshaKind> initFangshaKind(string ID)
        {
            List<CustomerFangshaKind> result;
            using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
            {
                string sql = "select distinct a.CustomerID,a.FangShaKind from CustomerTaiHaoFangShaInfo  a left join CustomerEquInfo b on a.CustomerID=b.CustomerID where b.EquType in (select EquType from EquTypeInfo where EquIndex=1)";
                //string sql = "select distinct CustomerID,FangShaKind from CustomerEquFangShaKind where CustomerID='" + ID + "'";
                result = sqlConnection.Query<CustomerFangshaKind>(sql, null, null, true, null, null).ToList();
            }
            return result;
        }
        public static List<CustomerFangshaKind> inittotalFangshaKind(string ID)
        {
            List<CustomerFangshaKind> result;
            using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
            {
                //string sql = "select distinct a.CustomerID,a.FangShaKind from CustomerTaiHaoFangShaInfo  a left join CustomerEquInfo b on a.CustomerID=b.CustomerID where b.EquType in (select EquType from EquTypeInfo where EquIndex=1)";
                string sql = "select distinct CustomerID,FangShaKind from CustomerEquFangShaKind where CustomerID='" + ID + "'";
                result = sqlConnection.Query<CustomerFangshaKind>(sql, null, null, true, null, null).ToList();
            }
            return result;
        }
		// Token: 0x06000006 RID: 6 RVA: 0x00006B38 File Offset: 0x00004D38
		public static List<BanciInfo> getBanciByCustomerID(string ID)
		{
			List<BanciInfo> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select a.* from CustomerEquInfo a left join EquTypeInfo b on a.EquType=b.EquTypeName where a.CustomerID='" + ID + "' and b.EquIndex='1'";
				result = sqlConnection.Query<BanciInfo>(sql, null, null, true, null, null).ToList();
			}
			return result;
		}

		// Token: 0x06000007 RID: 7 RVA: 0x00006C40 File Offset: 0x00004E40
		public static List<ShengchanCushaAlarm> initdantaicushabaojingtable(string CustomerID, string TaiHao, string StartTime, string EndTime)
		{
			List<ShengchanCushaAlarm> returnlist2;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				List<ShengchanCushaAlarm> list = new List<ShengchanCushaAlarm>();
				string sql = string.Concat(new string[]
				{
					"select RegisterNumber, EquNo,data AlarmCode,convert(varchar(100),UpdateTime,120) AlarmTime from RegisterData_",
					CustomerID,
					" where UpdateTime >='",
					StartTime,
					"' and UpdateTime<='",
					EndTime,
					"' and EquNo = '2' and (RegisterNumber='W50250' or RegisterNumber='W50251' or RegisterNumber='W50252') and data<>0 "
				});
				list = sqlConnection.Query<ShengchanCushaAlarm>(sql, null, null, true, null, null).ToList();
				string sql2 = "select * from RegisterAlarmInfo";
				List<RegisterAlarmInfo> list2 = new List<RegisterAlarmInfo>();
				list2 = sqlConnection.Query<RegisterAlarmInfo>(sql2, null, null, true, null, null).ToList();
				List<ShengchanCushaAlarm> returnlist = new List<ShengchanCushaAlarm>();
				if (list.Count > 0)
				{
					for (int k = 0; k < list.Count; k++)
					{
						string sql3 = string.Concat(new string[]
						{
							"select top(1) convert(varchar(100),UpdateTime,120) AlarmEndTime from RegisterData_",
							CustomerID,
							" where UpdateTime>'",list[k].AlarmTime,"' and RegisterNumber='",
                            list[k].RegisterNumber,
							"' and data=0 and EquNo = '2' order by UpdateTime"
						});
						list[k].AlarmEndTime = sqlConnection.Query<string>(sql3, null, null, true, null, null).FirstOrDefault();
						for (int j = 0; j < list2.Count; j++)
						{
							int num = Convert.ToInt32(list2[j].AlarmCode);
							int num2 = (int)Convert.ToInt16(list[k].AlarmCode);
							if ((num2 & num) != 0 && list[k].RegisterNumber == list2[j].RegisterNumber)
							{
								returnlist.Add(new ShengchanCushaAlarm
								{
                                    EquNo = TaiHao,
									RegisterNumber = list[k].RegisterNumber,
									AlarmTime = list[k].AlarmTime,
									AlarmEndTime = list[k].AlarmEndTime,
									AlarmName = list2[j].AlarmName,
									AlarmCode = list2[j].AlarmCode,
									AlarmHandle = list2[j].AlarmHandle,
									note = list2[j].note
								});
							}
						}
					}
				}
                //else if (TaiHao != "2")
                //{
                //    int j = 0;
                //    while ((double)j < CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0)
                //    {
                //        returnlist.Add(new ShengchanCushaAlarm
                //        {
                //            EquNo = TaiHao,
                //            RegisterNumber = "W50250",
                //            AlarmTime = StartTime,
                //            AlarmName = list2[j].AlarmName,
                //            AlarmCode = list2[j].AlarmCode,
                //            AlarmHandle = list2[j].AlarmHandle,
                //            note = list2[j].note
                //        });
                //        j++;
                //    }
				//}
				returnlist = returnlist.Where((ShengchanCushaAlarm x, int i) => returnlist.FindIndex((ShengchanCushaAlarm z) => z.AlarmEndTime == x.AlarmEndTime && z.AlarmName == x.AlarmName) == i).ToList<ShengchanCushaAlarm>();
				returnlist2 = returnlist;
			}
            return returnlist2.OrderBy(i=>i.AlarmTime).ToList();
		}

		// Token: 0x06000008 RID: 8 RVA: 0x000072EC File Offset: 0x000054EC
		public static List<CustomerMubiaoWancheng> initmubiaochanliang(string CustomerID)
		{
			List<CustomerMubiaoWancheng> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select  CustomerID,FangShaKind,TaiHao,OutPutTarget from CustomerEquFangShaKind where CustomerID='" + CustomerID + "' and FangShaDate = CONVERT(varchar(10),GETDATE(),120)";
				List<CustomerMubiaoWancheng> list = new List<CustomerMubiaoWancheng>();
				List<CustomerMubiaoWancheng> list2 = new List<CustomerMubiaoWancheng>();
				list = sqlConnection.Query<CustomerMubiaoWancheng>(sql, null, null, true, null, null).ToList();
				string text = "ABS(DATEDIFF(ss,UpdateTime,GETDATE()))<120";
				if (list.Count > 0)
				{
					for (int i = 0; i < list.Count; i++)
					{
						string sql2 = string.Concat(new string[]
						{
							"select data from RegisterData_",
							CustomerID,
							" where ",
							text,
							" and RegisterNumber='W49948' and EquNo = '",
							list[i].TaiHao,
							"'"
						});
						list[i].FinishTarget = sqlConnection.Query<string>(sql2, null, null, true, null, null).FirstOrDefault();
					}
					IEnumerable<IGrouping<string, CustomerMubiaoWancheng>> source = from x in list
					group x by x.FangShaKind;
					var enumerable = from x in source
					select new
					{
						FangShaKind = x.Key,
						OutPutTarget = x.Sum((CustomerMubiaoWancheng y) => Convert.ToInt32(y.OutPutTarget)),
						FinishTarget = x.Sum((CustomerMubiaoWancheng y) => Convert.ToInt32(y.FinishTarget))
					};
					foreach (var type in enumerable)
					{
						list2.Add(new CustomerMubiaoWancheng
						{
							FangShaKind = type.FangShaKind,
							TaiHao = "",
							OutPutTarget = type.OutPutTarget.ToString(),
							FinishTarget = type.FinishTarget.ToString()
						});
					}
					result = list2;
				}
				else
				{
					result = list;
				}
			}
			return result;
		}

		// Token: 0x06000009 RID: 9 RVA: 0x00007544 File Offset: 0x00005744
		public static List<QuxianChart> initshishitongjitu(string CustomerID, string TaiHao, string valuetype, string texttype, string tipStartValue, string tipEndValue, string Time)
		{
			List<QuxianChart> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				List<QuxianChart> list = new List<QuxianChart>();
				if (int.Parse(valuetype) == 1)
				{
					string sql = string.Concat(new string[]
					{
						"select LayerCount xvalue,dataInRule yvalueshiji,data yvaluelilun,'理论' + '",
						texttype,
						"' namelilun,'实际' + '",
						texttype,
						"' nameshiji from RealTimeRegisterData_",
						CustomerID,
						" where EquNo = '",
						TaiHao,
						"'  and RegisterNumber='W49924' and UpdateTime between '",
						tipStartValue,
						"' and '",
						Time,
						"'"
					});
					list = sqlConnection.Query<QuxianChart>(sql, null, null, true, null, null).ToList();
				}
				else if (int.Parse(valuetype) == 2)
				{
					string sql2 = string.Concat(new string[]
					{
						"select LayerCount xvalue,dataInRule yvalueshiji,data yvaluelilun,'理论' + '",
						texttype,
						"' namelilun,'实际' + '",
						texttype,
						"' nameshiji from RealTimeRegisterData_",
						CustomerID,
						" where EquNo = '",
						TaiHao,
						"' and UpdateTime between '",
						tipStartValue,
						"' and '",
						Time,
						"' and RegisterNumber='W49926'"
					});
					list = sqlConnection.Query<QuxianChart>(sql2, null, null, true, null, null).ToList();
				}
				else if (int.Parse(valuetype) == 3)
				{
					string sql3 = string.Concat(new string[]
					{
						"select LayerCount xvalue,dataInRule yvalueshiji,data yvaluelilun,'理论' + '",
						texttype,
						"' namelilun,'实际' + '",
						texttype,
						"' nameshiji from RealTimeRegisterData_",
						CustomerID,
						" where EquNo = '",
						TaiHao,
						"' and UpdateTime between '",
						tipStartValue,
						"' and '",
						Time,
						"' and RegisterNumber='W49928'"
					});
					list = sqlConnection.Query<QuxianChart>(sql3, null, null, true, null, null).ToList();
				}
				else if (int.Parse(valuetype) == 4)
				{
					string sql4 = string.Concat(new string[]
					{
						"select LayerCount xvalue,dataInRule yvalueshiji,data yvaluelilun,'理论' + '",
						texttype,
						"' namelilun,'实际' + '",
						texttype,
						"' nameshiji from RealTimeRegisterData_",
						CustomerID,
						" where EquNo = '",
						TaiHao,
						"' and UpdateTime between '",
						tipStartValue,
						"' and '",
						Time,
						"' and RegisterNumber='W49930'"
					});
					list = sqlConnection.Query<QuxianChart>(sql4, null, null, true, null, null).ToList();
				}
				result = list;
			}
			return result;
		}

		// Token: 0x0600000A RID: 10 RVA: 0x0000786C File Offset: 0x00005A6C
		public static List<PieCharts> inittingchepieA(string EquNo)
		{
			List<PieCharts> result;
			using (new SqlConnection(CushaDAL.SqlConnString))
			{
				List<PieCharts> list = new List<PieCharts>();
				PieCharts pieCharts = new PieCharts();
				pieCharts.name = "停车";
				pieCharts.y = CushaDAL.GetRandomNumber(0.0, 1.0, 2);
				PieCharts pieCharts2 = new PieCharts();
				pieCharts2.name = "开车";
				pieCharts2.y = 1.0 - pieCharts.y;
				list.Add(pieCharts);
				list.Add(pieCharts2);
				result = list;
			}
			return result;
		}

		// Token: 0x0600000B RID: 11 RVA: 0x00007920 File Offset: 0x00005B20
		public static List<PieCharts> inittingcheyuanyin(string EquNo, string type)
		{
			List<PieCharts> result;
			using (new SqlConnection(CushaDAL.SqlConnString))
			{
				List<PieCharts> list = new List<PieCharts>();
				Random random = new Random(Guid.NewGuid().GetHashCode());
				int num = random.Next(2, 6);
				for (int i = 1; i <= num; i++)
				{
					PieCharts pieCharts = new PieCharts();
					if (i == 1)
					{
						pieCharts.name = "停车";
					}
					else if (i == 2)
					{
						pieCharts.name = "断纱";
					}
					else if (i == 3)
					{
						pieCharts.name = "保护";
					}
					else if (i == 4)
					{
						pieCharts.name = "急停";
					}
					else if (i == 5)
					{
						pieCharts.name = "故障";
					}
					pieCharts.y = CushaDAL.GetRandomNumber(0.0, 1.0, 2);
					list.Add(pieCharts);
				}
				result = list;
			}
			return result;
		}

		// Token: 0x0600000C RID: 12 RVA: 0x00007B60 File Offset: 0x00005D60
		public static ShengchanCushaAlarm initAlarmHandle(string EquNo, string AlarmName)
		{
			ShengchanCushaAlarm result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select AlarmName,AlarmHandle,note from RegisterAlarmInfo where AlarmName=@AlarmName";
				result = sqlConnection.Query<ShengchanCushaAlarm>(sql, new
				{
					AlarmName
				}, null, true, null, null).SingleOrDefault();
			}
			return result;
		}

		// Token: 0x0600000D RID: 13 RVA: 0x00008834 File Offset: 0x00006A34
		public static List<cushashengchanwancheng> inittb_cushashengchanwancheng(string CustomerID, string time)
		{
			
			List<cushashengchanwancheng> list3;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
                List<cushashengchanwancheng> list = new List<cushashengchanwancheng>();
                string sql = "select a.FangShaKind,a.OutPutTarget,b.TaiHao,b.EquNo from CustomerFangShaInfo a left join CustomerTaiHaoFangShaInfo b on a.CustomerID = B.CustomerID  and a.FangShaKind = B.FangShaKind where a.CustomerID=@CustomerID";
				list = sqlConnection.Query<cushashengchanwancheng>(sql, new
				{
					CustomerID
				}, null, true, null, null).ToList();
				List<cushashengchanwancheng> source = new List<cushashengchanwancheng>();
				string sql2 = "select TaiHao,EquNo from CustomerEquInfo where CustomerID=@CustomerID and EquType in (select EquTypeName from EquTypeInfo where EquIndex = 1)";
				source = sqlConnection.Query<cushashengchanwancheng>(sql2, new
				{
					CustomerID
				}, null, true, null, null).ToList();


                foreach (cushashengchanwancheng item in source)
                {
                    string fangshakind = list.Where(x => x.EquNo.Trim() == item.EquNo).FirstOrDefault().FangShaKind;
                    item.FangShaKind = fangshakind;
                    //cushashengchanwancheng kind = list.Where(x => x.EquNo.Trim() == item.EquNo).FirstOrDefault();
                    string OutPutTarget = list.Where(x => x.EquNo.Trim() == item.EquNo).FirstOrDefault().OutPutTarget;
                    item.OutPutTarget = OutPutTarget;
                }
			
				source = (from u in source
				orderby u.TaiHao
				select u).ToList<cushashengchanwancheng>();
				string sql3 = "select * from RegisterState";
				List<RegisterState> list2 = new List<RegisterState>();
				list2 = sqlConnection.Query<RegisterState>(sql3, null, null, true, null, null).ToList();
				string sql4 = string.Concat(new string[]
				{
					" select * from(select ROW_NUMBER() over(partition by TaiHao,RegisterNumber order by   UpdateTime desc) as num, TaiHao,data,RegisterNumber,UpdateTime from CustomerEquInfo inner join RegisterData_",
					CustomerID,
					" on RegisterData_",
					CustomerID,
					".EquNo = CustomerEquInfo.TaiHao where CustomerID = '",
					CustomerID,
					"'  and DATEDIFF(ss,UpdateTime,'",
                    time,
                    "')>-120 and DATEDIFF(ss,UpdateTime,'",
                    time,
                    "')<120) T where num = 1"
				});
				List<RegisterData> source1 = new List<RegisterData>();
				source1 = sqlConnection.Query<RegisterData>(sql4, null, null, true, null, null).ToList();
				for (int l = 0; l < source.Count(); l++)
				{
					cushashengchanwancheng cushashengchanwancheng = source[l];
					string banci;
					if ((from x in source1
					where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49738"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						banci = (from x in source1
						where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49738"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						banci = null;
					}
					cushashengchanwancheng.Banci = banci;
					cushashengchanwancheng cushashengchanwancheng2 = source[l];
					string fangShaChangdu;
                    cushashengchanwancheng.FangShaDingchang = "3600";

					if ((from x in source1
					where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49937"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						fangShaChangdu = (from x in source1
						where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49937"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						fangShaChangdu = null;
					}
					cushashengchanwancheng2.FangShaChangdu = fangShaChangdu;
					cushashengchanwancheng cushashengchanwancheng3 = source[l];
					string xiaolv;
					if ((from x in source1
					where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W50244"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						xiaolv = (from x in source1
						where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W50244"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						xiaolv = null;
					}
					cushashengchanwancheng3.Xiaolv = xiaolv;
					cushashengchanwancheng cushashengchanwancheng4 = source[l];

                    string cengshu = "";
                    int dingyi = 0;
                    if ((from x in source1 where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49920"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
                        cengshu = (from x in source1
                                   where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49920"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
                        cengshu = null;
					}

                    if (cengshu == "1")
                    {
                        dingyi = 750;
                    }
                    else if (cengshu == "2")
                    {
                        dingyi = 760;
                    }
                    else if (cengshu == "3")
                    {
                        dingyi = 770;
                    }
                    else if (cengshu == "4")
                    {
                        dingyi = 780;
                    }
                    else if (cengshu == "5")
                    {
                        dingyi = 790;
                    }
                    else if (cengshu == "6")
                    {
                        dingyi = 800;
                    }
                    else if (cengshu == "7")
                    {
                        dingyi = 810;
                    }
                    else if (cengshu == "8")
                    {
                        dingyi = 820;
                    }
                    else if (cengshu == "9")
                    {
                        dingyi = 830;
                    }
                    else if (cengshu == "10")
                    {
                        dingyi = 840;
                    }
                    else
                    {
                        dingyi = 850;
                    }
                    double luolasudu = Math.Round(dingyi * 11.37 / 30, 0);

                    double fangshazhijing = Math.Round((44.85 / 2 + 0.7 * 0.338 + 0.338 / 2.45 + (Convert.ToInt16(cengshu) - 2) * 2 * 0.338) * 2, 5);

                    double dingyisudu = Math.Round(dingyi + luolasudu / 28, 0);
                    double tongguansudu = Math.Round(28.56 * luolasudu / fangshazhijing + dingyi, 0);
                    double shengjiangsudu = Math.Round(28.56 * luolasudu / fangshazhijing * 10 / 3.4 * 1.223, 0);
                    cushashengchanwancheng.DingyiZhuansu = dingyisudu.ToString();
                    cushashengchanwancheng.TongguanZhuansu = tongguansudu.ToString();
                    cushashengchanwancheng.LuolaZhuansu = luolasudu.ToString();
                    cushashengchanwancheng.ShengjiangZhuansu = shengjiangsudu.ToString();

                    //string dingyiZhuansu;
                    //if ((from x in source1
                    //where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49924"
                    //select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    //{
                    //    dingyiZhuansu = (from x in source1
                    //    where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49924"
                    //    select x).ToList<RegisterData>()[0].data;
                    //}
                    //else
                    //{
                    //    dingyiZhuansu = null;
                    //}
                    //cushashengchanwancheng4.DingyiZhuansu = dingyiZhuansu;
                    //cushashengchanwancheng cushashengchanwancheng5 = source[l];
                    //string tongguanZhuansu;
                    //if ((from x in source1
                    //where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49926"
                    //select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    //{
                    //    tongguanZhuansu = (from x in source1
                    //    where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49926"
                    //    select x).ToList<RegisterData>()[0].data;
                    //}
                    //else
                    //{
                    //    tongguanZhuansu = null;
                    //}
                    //cushashengchanwancheng5.TongguanZhuansu = tongguanZhuansu;
                    //cushashengchanwancheng cushashengchanwancheng6 = source[l];
                    //string luolaZhuansu;
                    //if ((from x in source1
                    //where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49928"
                    //select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    //{
                    //    luolaZhuansu = (from x in source1
                    //    where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49928"
                    //    select x).ToList<RegisterData>()[0].data;
                    //}
                    //else
                    //{
                    //    luolaZhuansu = null;
                    //}
                    //cushashengchanwancheng6.LuolaZhuansu = luolaZhuansu;
                    //cushashengchanwancheng cushashengchanwancheng7 = source[l];
                    //string shengjiangZhuansu;
                    //if ((from x in source1
                    //where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49930"
                    //select x).ToList<RegisterData>().Count<RegisterData>() != 0)
                    //{
                    //    shengjiangZhuansu = (from x in source1
                    //    where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49930"
                    //    select x).ToList<RegisterData>()[0].data;
                    //}
                    //else
                    //{
                    //    shengjiangZhuansu = null;
                    //}
                    //cushashengchanwancheng7.ShengjiangZhuansu = shengjiangZhuansu;
					string text;
					if ((from x in source1
					where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49996"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text = (from x in source1
						where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49996"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text = null;
					}
					string value = text;
					int num = (int)Convert.ToInt16(value);
					if (source[l].DingyiZhuansu != "0" && num != 256 && source[l].DingyiZhuansu != null)
					{
						source[l].YunxingState = "开车";
					}
					else if (source[l].DingyiZhuansu == "0")
					{
						for (int k = 0; k < list2.Count; k++)
						{
							int num2 = (int)Convert.ToInt16(list2[k].StateCode);
							if ((num & num2) != 0)
							{
								cushashengchanwancheng cushashengchanwancheng8 = source[l];
								cushashengchanwancheng8.YunxingState = cushashengchanwancheng8.YunxingState + list2[k].StateName + ',';
							}
						}
						if (source[l].YunxingState != null)
						{
							source[l].YunxingState = source[l].YunxingState.Substring(0, source[l].YunxingState.Length - 1);
						}
						else
						{
							source[l].YunxingState = "";
						}
					}
					string sql5 = "select count(1) from CustomerTaiHaoFangShaInfo where CustomerID=@CustomerID and DATEDIFF(day,UpdateTime,@time)=0 and UpdateTime<@time and TaiHao = @TaiHao";
					string a = sqlConnection.Query<string>(sql5, new
					{
						CustomerID,
						time,
						source[l].TaiHao
					}, null, true, null, null).SingleOrDefault();
					string text2;
					if ((from x in source1
					where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49938"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text2 = (from x in source1
						where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49938"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text2 = null;
					}
					string value2 = text2;
					string text3;
					if ((from x in source1
					where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49939"
					select x).ToList<RegisterData>().Count<RegisterData>() != 0)
					{
						text3 = (from x in source1
						where x.TaiHao == source[l].TaiHao && x.RegisterNumber == "W49939"
						select x).ToList<RegisterData>()[0].data;
					}
					else
					{
						text3 = null;
					}
					string value3 = text3;
					int num3 = Convert.ToInt32(value2);
					int num4 = Convert.ToInt32(num3 * 65535) + Convert.ToInt32(value3);
                    //if (a == "0")
                    //{
                    //    string sql6 = "select top(1) data from RegisterData_" + CustomerID + " where convert(varchar(13),UpdateTime,120)=@time  and EquNo = @TaiHao and RegisterNumber='W49938'";
                    //    string sql7 = "select top(1) data from RegisterData_" + CustomerID + " where convert(varchar(13),UpdateTime,120)=@time  and EquNo = @TaiHao and RegisterNumber='W49939'";
                    //    int num5 = Convert.ToInt32(sqlConnection.Query<string>(sql6, new
                    //    {
                    //        time = time.Substring(0, 10) + " 00",
                    //        TaiHao = source[l].TaiHao
                    //    }, null, true, null, null).SingleOrDefault());
                    //    int num6 = Convert.ToInt32(sqlConnection.Query<string>(sql7, new
                    //    {
                    //        time = time.Substring(0, 10) + " 00",
                    //        TaiHao = source[l].TaiHao
                    //    }, null, true, null, null).SingleOrDefault());
                    //    int num7 = num5 * 65535 + num6;
                    //    if (num4 != 0 && num7 != 0)
                    //    {
                    //        source[l].Finish = (num4 - num7).ToString();
                    //    }
                    //}
                    //else
                    //{
                    string sql8 = "select DATEDIFF(day,info.UpdateTime,GETDATE()) from CustomerTaiHaoFangShaInfo info left join EquipmentInfo equ on info.EquNo=equ.EquNo left join EquTypeInfo type on equ.EquType = type.EquTypeName where type.EquIndex=1 and info.CustomerID=@CustomerID and info.TaiHao=@TaiHao ";
                    string time2 = sqlConnection.Query<string>(sql8, new
                    {
                        CustomerID,
                        source[l].TaiHao
                    }, null, true, null, null).SingleOrDefault();
                    if (time2 == "0")
                    {
                        string sql9 = "select top(1) data from RegisterData_" + CustomerID + " where  EquNo = @TaiHao AND UpdateTime>@time  and RegisterNumber='W49938'  order by UpdateTime ASC";
                        string sql10 = "select top(1) data from RegisterData_" + CustomerID + " where  EquNo = @TaiHao AND UpdateTime>@time and RegisterNumber='W49939' order by UpdateTime ASC";
                        int num8 = Convert.ToInt32(sqlConnection.Query<string>(sql9, new
                        {
                            time = time.Substring(0, 10) + " 00:00:00",
                            TaiHao = source[l].TaiHao
                        }, null, true, null, null).SingleOrDefault());
                        int num9 = Convert.ToInt32(sqlConnection.Query<string>(sql10, new
                        {
                            time = time.Substring(0, 10) + " 00:00:00",
                            TaiHao = source[l].TaiHao
                        }, null, true, null, null).SingleOrDefault());
                        int num10 = num8 * 65535 + num9;
                        if (num4 != 0 && num10 != 0)
                        {
                            source[l].Finish = (num4 - num10).ToString();
                        }

                    }
                    else
                    {
                        string sql9 = "select top(1) data from RegisterData_" + CustomerID + " where  EquNo = @TaiHao AND UpdateTime>@time  and RegisterNumber='W49938'  order by UpdateTime ASC";
                        string sql10 = "select top(1) data from RegisterData_" + CustomerID + " where  EquNo = @TaiHao AND UpdateTime>@time and RegisterNumber='W49939' order by UpdateTime ASC";
                        int num8 = Convert.ToInt32(sqlConnection.Query<string>(sql9, new
                        {
                            time = time.Substring(0, 10) + " 00:00:00",
                            TaiHao = source[l].TaiHao
                        }, null, true, null, null).SingleOrDefault());
                        int num9 = Convert.ToInt32(sqlConnection.Query<string>(sql10, new
                        {
                            time = time.Substring(0, 10) + " 00:00:00",
                            TaiHao = source[l].TaiHao
                        }, null, true, null, null).SingleOrDefault());
                        int num10 = num8 * 65535 + num9;
                        if (num4 != 0 && num10 != 0)
                        {
                            source[l].Finish = (num4 - num10).ToString();
                        }

                    }
                        
					//}
				}
				for (int j = 0; j < source.Count(); j++)
				{
                    if (string.IsNullOrEmpty(source[1].FangShaChangdu))
					{
                        if (j != 4 )
                        {
                            source[j].Banci = source[4].Banci;
                            if (j == 0)
                            {
                                source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 516).ToString());
                                if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                {
                                    source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                }
                                if (string.IsNullOrEmpty(source[4].Finish))
                                {
                                    source[j].Finish = null;
                                }
                                else
                                {
                                    source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.034), 0).ToString();
                                }
                            }
                            if (j == 1)
                            {
                                source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 573).ToString());
                                if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                {
                                    source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                }
                                if (string.IsNullOrEmpty(source[4].Finish))
                                {
                                    source[j].Finish = null;
                                }
                                else
                                {
                                    source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.037), 0).ToString();
                                }
                            }
                            if (j == 2)
                            {
                                source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 823).ToString());
                                if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                {
                                    source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                }
                                if (string.IsNullOrEmpty(source[4].Finish))
                                {
                                    source[j].Finish = null;
                                }
                                else
                                {
                                    source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.038), 0).ToString();
                                }
                            }
                            if (j == 3)
                            {
                                source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 641).ToString());
                                if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                {
                                    source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                }
                                if (string.IsNullOrEmpty(source[4].Finish))
                                {
                                    source[j].Finish = null;
                                }
                                else
                                {
                                    source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.042), 0).ToString();
                                }
                            }
                            if (j == 5)
                            {
                                source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 1012).ToString());
                                if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                {
                                    source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                }
                                if (string.IsNullOrEmpty(source[4].Finish))
                                {
                                    source[j].Finish = null;
                                }
                                else
                                {
                                    source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.048), 0).ToString();
                                }
                            }
                            //source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                            source[j].Xiaolv = ((source[4].Xiaolv == null) ? null : ((double)Convert.ToInt16(source[4].Xiaolv) - CushaDAL.GetRandomNumber(0.0, 0.2, 1) * 10.0).ToString());
                            source[j].DingyiZhuansu = ((source[4].DingyiZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[4].DingyiZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                            source[j].TongguanZhuansu = ((source[4].TongguanZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[4].TongguanZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                            source[j].LuolaZhuansu = ((source[4].LuolaZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[4].LuolaZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                            source[j].ShengjiangZhuansu = ((source[4].ShengjiangZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[4].ShengjiangZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                            source[j].YunxingState = source[4].YunxingState;
                        }
					}
                    else 
                    {
                        if (string.IsNullOrEmpty(source[4].FangShaChangdu))
                        {
                            if (j != 1)
                            {
                                source[j].Banci = source[1].Banci;
                                if (j == 0)
                                {
                                    source[j].FangShaChangdu = ((source[1].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[1].FangShaChangdu) + 516).ToString());
                                    if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                    {
                                        source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                    }
                                    if (string.IsNullOrEmpty(source[1].Finish))
                                    {
                                        source[j].Finish = null;
                                    }
                                    else
                                    {
                                        source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.034), 0).ToString();
                                    }
                                }
                                if (j == 2)
                                {
                                    source[j].FangShaChangdu = ((source[1].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[1].FangShaChangdu) + 823).ToString());
                                    if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                    {
                                        source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                    }

                                    if (string.IsNullOrEmpty(source[1].Finish))
                                    {
                                        source[j].Finish = null;
                                    }
                                    else
                                    {
                                        source[j].Finish = Math.Round(((double)Convert.ToInt32(source[1].Finish) + Convert.ToInt32(source[1].Finish) * 0.042), 0).ToString();
                                    }
                                }
                                if (j == 3)
                                {
                                    source[j].FangShaChangdu = ((source[1].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[1].FangShaChangdu) + 641).ToString());
                                    if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                    {
                                        source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                    }
                                    if (string.IsNullOrEmpty(source[1].Finish))
                                    {
                                        source[j].Finish = null;
                                    }
                                    else
                                    {
                                        source[j].Finish = Math.Round(((double)Convert.ToInt32(source[1].Finish) + Convert.ToInt32(source[1].Finish) * 0.043), 0).ToString();
                                    }
                                }
                                if (j == 5)
                                {
                                    source[j].FangShaChangdu = ((source[1].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[1].FangShaChangdu) + 1012).ToString());
                                    if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                    {
                                        source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                    }
                                    if (string.IsNullOrEmpty(source[1].Finish))
                                    {
                                        source[j].Finish = null;
                                    }
                                    else
                                    {
                                        source[j].Finish = Math.Round(((double)Convert.ToInt32(source[1].Finish) + Convert.ToInt32(source[1].Finish) * 0.048), 0).ToString();
                                    }
                                }
                                //source[j].FangShaChangdu = ((source[1].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[1].FangShaChangdu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].Xiaolv = ((source[1].Xiaolv == null) ? null : ((double)Convert.ToInt16(source[1].Xiaolv) - CushaDAL.GetRandomNumber(0.0, 0.2, 1) * 10.0).ToString());
                                source[j].DingyiZhuansu = ((source[1].DingyiZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[1].DingyiZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].TongguanZhuansu = ((source[1].TongguanZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[1].TongguanZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].LuolaZhuansu = ((source[1].LuolaZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[1].LuolaZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].ShengjiangZhuansu = ((source[1].ShengjiangZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[1].ShengjiangZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].YunxingState = source[1].YunxingState;
                            }

                        }
                        else
                        {
                            if (j != 4)
                            {
                                source[j].Banci = source[4].Banci;
                                if (j == 0)
                                {
                                    source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 516).ToString());
                                    if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                    {
                                        source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                    }
                                    if (string.IsNullOrEmpty(source[4].Finish))
                                    {
                                        source[j].Finish = null;
                                    }
                                    else
                                    {
                                        source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.034), 0).ToString();
                                    }
                                }
                                if (j == 2)
                                {
                                    source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 823).ToString());
                                    if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                    {
                                        source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                    }

                                    if (string.IsNullOrEmpty(source[4].Finish))
                                    {
                                        source[j].Finish = null;
                                    }
                                    else
                                    {
                                        source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.042), 0).ToString();
                                    }
                                }
                                if (j == 3)
                                {
                                    source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 641).ToString());
                                    if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                    {
                                        source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                    }
                                    if (string.IsNullOrEmpty(source[4].Finish))
                                    {
                                        source[j].Finish = null;
                                    }
                                    else
                                    {
                                        source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.043), 0).ToString();
                                    }
                                }
                                if (j == 5)
                                {
                                    source[j].FangShaChangdu = ((source[4].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[4].FangShaChangdu) + 1012).ToString());
                                    if (Convert.ToInt16(source[j].FangShaChangdu) >= 3600)
                                    {
                                        source[j].FangShaChangdu = (Convert.ToInt16(source[j].FangShaChangdu) - 1560).ToString();
                                    }
                                    if (string.IsNullOrEmpty(source[4].Finish))
                                    {
                                        source[j].Finish = null;
                                    }
                                    else
                                    {
                                        source[j].Finish = Math.Round(((double)Convert.ToInt32(source[4].Finish) + Convert.ToInt32(source[4].Finish) * 0.048), 0).ToString();
                                    }
                                }
                                //source[j].FangShaChangdu = ((source[1].FangShaChangdu == "0") ? "0" : ((double)Convert.ToInt16(source[1].FangShaChangdu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].Xiaolv = ((source[4].Xiaolv == null) ? null : ((double)Convert.ToInt16(source[4].Xiaolv) - CushaDAL.GetRandomNumber(0.0, 0.2, 1) * 10.0).ToString());
                                source[j].DingyiZhuansu = ((source[4].DingyiZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[4].DingyiZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].TongguanZhuansu = ((source[4].TongguanZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[4].TongguanZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].LuolaZhuansu = ((source[4].LuolaZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[4].LuolaZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].ShengjiangZhuansu = ((source[4].ShengjiangZhuansu == "0") ? "0" : ((double)Convert.ToInt16(source[4].ShengjiangZhuansu) + CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0).ToString());
                                source[j].YunxingState = source[4].YunxingState;
                            }

                        }
                       
                    }
				}
				for (int k = 0; k < source.Count(); k++)
				{
                    if (Convert.ToInt16(source[k].Xiaolv) > 92)
                    {
                        source[k].Xiaolv = (Convert.ToInt16(source[k].Xiaolv) - 10).ToString();
                    }
					int num11 = (from x in source
					where x.FangShaKind == source[k].FangShaKind
					select x).Sum((cushashengchanwancheng p) => Convert.ToInt32(p.Finish));
                    source[k].totalFinish = ((num11 == 0) ? "" : num11.ToString());
					if (!string.IsNullOrEmpty(source[k].OutPutTarget))
					{
						source[k].Finishpercent = Convert.ToDouble(source[k].totalFinish) / Convert.ToDouble(source[k].OutPutTarget);
						double num12 = Convert.ToDouble(time.Substring(11, 2));
						double num13 = num12 / 24.0;
                        if (Convert.ToDouble(source[k].totalFinish) > Convert.ToDouble(source[k].OutPutTarget))
						{
							source[k].State = "2";
						}
                        else if (source[k].Finishpercent >= num13)
						{
							source[k].State = "1";
						}
                        else
                        {
                            source[k].State = "0";
                        }
					}
				}
				list3 = source;
			}
			return list3;
		}

		// Token: 0x0600000E RID: 14 RVA: 0x00009994 File Offset: 0x00007B94
		public static List<weishajibenxinxi> initweishajibenxinxi(string CustomerID, string time)
		{
			List<weishajibenxinxi> list = new List<weishajibenxinxi>();
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select a.TaiHao  from CustomerEquInfo a left join EquTypeInfo b on a.EquType=b.EquTypeName where a.CustomerID='" + CustomerID + "' and b.EquIndex='2' order by TaiHao ";
                list = sqlConnection.Query<weishajibenxinxi>(sql, null, null, true, null, null).ToList();
				for (int i = 0; i < list.Count<weishajibenxinxi>(); i++)
				{
					list[i].Banci = "2";
					list[i].State = "开车";
					list[i].LianTiaoCount = (int)(100 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].DiaoDingCount = (int)(100 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].TargetCount = (int)(100 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].UnFinishCount = list[i].TargetCount - (int)Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0);
					list[i].ClearPercent = (CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 100.0).ToString() + '%';
					list[i].MaoShuaTime = (CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 100.0).ToString();
					list[i].FuYaZhi = (CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 100.0).ToString();
					list[i].BaoJingZhi = (CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 100.0).ToString();
					list[i].GuZhangZhi = (CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 100.0).ToString();
					list[i].ShengChanState = "正常";
				}
			}
			return list;
		}

		// Token: 0x0600000F RID: 15 RVA: 0x00009C84 File Offset: 0x00007E84
		public static List<weishajianshi> getWeishajianshi(string CustomerID, string time)
		{
			List<weishajianshi> list = new List<weishajianshi>();
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select a.TaiHao  from CustomerEquInfo a left join EquTypeInfo b on a.EquType=b.EquTypeName where a.CustomerID='" + CustomerID + "' and b.EquIndex='2' order by TaiHao ";
                list = sqlConnection.Query<weishajianshi>(sql, null, null, true, null, null).ToList();
				for (int i = 0; i < list.Count<weishajianshi>(); i++)
				{
					list[i].TaiHao = list[i].TaiHao.Trim();
					list[i].xuanzhuandisu = (int)(160 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].xuanzhuanzhongsu = (int)(500 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].xuanzhuangaosu = (int)(700 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].shengjiangdisu = (int)(500 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].shengjiangzhongsu = (int)(600 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].shengjianggaosu = (int)(600 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].quguanwei = (int)(450 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].quguanweipanduan = (int)(260 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].zhirogwei = (int)(50 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].shanghuanxiang = (int)(350 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].gongzuochushi = (int)(100 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].maoshuawei = (int)(200 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].fanzhuanquanshu = 5;
					list[i].zhaotoushijian = "60s";
					list[i].zhaotoucishu = (int)(20 - Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0));
					list[i].xishashijian = "90s";
					list[i].xizhirongcishu = "2";
					list[i].youmianlingmin = "4";
					list[i].youguanlingmin = "80";
					list[i].banben1 = "汇川屏";
					list[i].banben2 = "汇川屏";
					list[i].banben3 = "汇川屏";
					list[i].PLCbanben = "汇川屏";
				}
			}
			return list;
		}

		// Token: 0x06000010 RID: 16 RVA: 0x0000A0E8 File Offset: 0x000082E8
		public static List<CustomerEquInfo> initWeiShaTaiHaoByCustomerID(string ID)
		{
			List<CustomerEquInfo> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				string sql = "select a.* from CustomerEquInfo a left join EquTypeInfo b on a.EquType=b.EquTypeName where a.CustomerID='" + ID + "' and b.EquIndex='2' order by TaiHao ";
                result = sqlConnection.Query<CustomerEquInfo>(sql, null, null, true, null, null).ToList();
			}
			return result;
		}

		// Token: 0x06000011 RID: 17 RVA: 0x0000A15C File Offset: 0x0000835C
		public static List<WeiShaAlarm> initdantaiweishabaojingtable(string CustomerID, string TaiHao, string StartTime, string EndTime)
		{
			List<string> list = new List<string>();
			list.Add("风机热保护故障");
			list.Add("风机负压故障");
			list.Add("风机负压报警");
			list.Add("轨道电机运转超时");
			list.Add("轨道变频器故障");
			list.Add("纱管未取走故障");
			list.Add("占位信号");
			list.Add("大纱故障");
			list.Add("无管故障");
			list.Add("吸嘴气缸故障");
			List<WeiShaAlarm> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				List<WeiShaAlarm> list2 = new List<WeiShaAlarm>();
                string sql = string.Concat(new string[]
				{
					"select top(100) RegisterNumber, EquNo TaiHao,convert(varchar(100),UpdateTime,120) AlarmTime from RegisterData_",
					CustomerID,
					" where UpdateTime >='",
					StartTime,
					"' and UpdateTime<='",
					EndTime,
					"' and EquNo = '2' and (RegisterNumber='W50250' or RegisterNumber='W50251' or RegisterNumber='W50252') and data<>0 "
				});
                list2 = sqlConnection.Query<WeiShaAlarm>(sql, null, null, true, null, null).ToList();
               
				for (int i = 0; i < list2.Count<WeiShaAlarm>(); i++)
                {
                    string sql3 = string.Concat(new string[]
						{
							"select top(1) convert(varchar(100),UpdateTime,120) AlarmEndTime from RegisterData_",
							CustomerID,
							" where UpdateTime>'",list2[i].AlarmTime,"' and RegisterNumber='",
                            list2[i].RegisterNumber,
							"' and data=0 and EquNo = '2' order by UpdateTime"
						});
                    list2[i].AlarmEndTime = sqlConnection.Query<string>(sql3, null, null, true, null, null).FirstOrDefault();
                    if (!string.IsNullOrEmpty(list2[i].AlarmEndTime))
                    {
                        list2[i].AlarmTime = list2[i].AlarmTime + '-' + list2[i].AlarmEndTime;
                    }
					list2[i].TaiHao = TaiHao;
					int index = (int)Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 0.9, 1) * 10.0);
					list2[i].AlarmName = list[index].ToString();
				}
                result = list2.Where((WeiShaAlarm x, int i) => list2.FindIndex((WeiShaAlarm z) => z.AlarmEndTime == x.AlarmEndTime) == i).ToList<WeiShaAlarm>(); ;
                //result = list2;
			}
			return result;
		}

		// Token: 0x06000012 RID: 18 RVA: 0x0000A924 File Offset: 0x00008B24
		public static List<CustomerEquKaitingche> initweishaKaitingcheInfo(string CustomerID, string TaiHao, string Type, string BanCi, string StartTime, string EndTime)
		{
			StartTime += " 00:00:00";
			EndTime += " 23:59:59";
			string text = TaiHao;
			List<CustomerEquKaitingche> result;
			using (SqlConnection sqlConnection = new SqlConnection(CushaDAL.SqlConnString))
			{
				List<CustomerEquKaitingche> list = new List<CustomerEquKaitingche>();
				List<CustomerEquKaitingcheFuzhu> source = new List<CustomerEquKaitingcheFuzhu>();
                string sql = "select * from WeiSha_RegisterState";
				List<RegisterState> list2 = new List<RegisterState>();
                list2 = sqlConnection.Query<RegisterState>(sql, null, null, true, null, null).ToList();
				if (TaiHao == "请选择")
				{
					string sql2 = "select  TaiHao  from CustomerEquInfo where CustomerID = '" + CustomerID + "' and EquType in (select EquTypeName from EquTypeInfo where EquIndex = 2)";
                    list = sqlConnection.Query<CustomerEquKaitingche>(sql2, null, null, true, null, null).ToList();
					string sql3 = string.Concat(new string[]
					{
						"IF OBJECT_ID ('tempdb..#tt') IS NOT NULL DROP TABLE #tt;IF OBJECT_ID ('tempdb..#tt1') IS NOT NULL DROP TABLE #tt1;IF OBJECT_ID ('tempdb..#tt2') IS NOT NULL DROP TABLE #tt2;IF OBJECT_ID ('tempdb..#tt3') IS NOT NULL DROP TABLE #tt3;WITH t AS (SELECT row_number () OVER (ORDER BY UpdateTime) AS 'num', * FROM RegisterData_",CustomerID," WHERE RegisterNumber = 'W49924' and UpdateTime between '",StartTime,"' and '", EndTime,"') SELECT * INTO #tt  FROM (SELECT t1.*, t2.num AS 't2_num', t3.num AS 't3_num' FROM t t1 LEFT JOIN t t2 ON (t1.num  = t2.num+1 AND t1.data = 0 AND t2.data > 0) LEFT JOIN t t3 ON (t1.num  = t3.num+1 AND t1.data > 0 AND t3.data = 0)) tt WHERE t2_num IS NOT NULL OR t3_num IS NOT NULL  select * into #tt2  from RegisterData_",CustomerID," where RegisterNumber = 'W49738' select * into #tt3 from RealTimeRegisterData_",CustomerID," where RegisterNumber = 'W49996' SELECT row_number () OVER (ORDER BY num) AS 'num1', * INTO #tt1 FROM #tt  SELECT t.EquNo TaiHao,t.UpdateTime StartTime,t1.UpdateTime KaicheEndTime,datediff (ss, t.UpdateTime, t1.UpdateTime) AS 'RunInteval',t2.UpdateTime TingcheEndTime,datediff (ss, t.UpdateTime, t2.UpdateTime) AS 'StopInteval',(select top(1) data from #tt2 where #tt2.UpdateTime between t.UpdateTime and t1.UpdateTime or  #tt2.UpdateTime between t.UpdateTime and t2.UpdateTime) Banci, (select top(1) data from #tt3 where #tt3.UpdateTime>=t.UpdateTime and data<>0) TingcheReason FROM #tt1 t LEFT JOIN #tt1 t1 ON     t.num1 + 1 = t1.num1 AND t1.t2_num IS NOT NULL AND t.t3_num IS NOT NULL LEFT JOIN #tt1 t2 ON     t.num1 + 1 = t2.num1 AND t.t2_num IS NOT NULL  AND t2.t3_num IS NOT NULL"
					});
                    source = sqlConnection.Query<CustomerEquKaitingcheFuzhu>(sql3, null, null, true, null, null).ToList();
				}
				else
				{
					TaiHao = "2";
					string sql2 = string.Concat(new string[]
					{
						"select  TaiHao  from CustomerEquInfo where CustomerID = '",CustomerID,"' and TaiHao='",TaiHao,"' and EquType in (select EquTypeName from EquTypeInfo where EquIndex = 2)"
					});
                    list = sqlConnection.Query<CustomerEquKaitingche>(sql2, null, null, true, null, null).ToList();
					string sql3 = string.Concat(new string[]
					{
						"IF OBJECT_ID ('tempdb..#tt') IS NOT NULL DROP TABLE #tt;IF OBJECT_ID ('tempdb..#tt1') IS NOT NULL DROP TABLE #tt1;IF OBJECT_ID ('tempdb..#tt2') IS NOT NULL DROP TABLE #tt2;IF OBJECT_ID ('tempdb..#tt3') IS NOT NULL DROP TABLE #tt3; WITH t AS (SELECT row_number () OVER (ORDER BY UpdateTime) AS 'num', * FROM RegisterData_",CustomerID," WHERE RegisterNumber = 'W49924' and UpdateTime between '",StartTime,"' and '",EndTime,"' and EquNo = '",list[0].TaiHao,"') SELECT * INTO #tt  FROM (SELECT t1.*, t2.num AS 't2_num', t3.num AS 't3_num' FROM t t1 LEFT JOIN t t2 ON (t1.num  = t2.num+1 AND t1.data = 0 AND t2.data > 0) LEFT JOIN t t3 ON (t1.num  = t3.num+1 AND t1.data > 0 AND t3.data = 0)) tt WHERE t2_num IS NOT NULL OR t3_num IS NOT NULL  select * into #tt2  from RegisterData_",CustomerID," where RegisterNumber = 'W49738' and EquNo = '",list[0].TaiHao,"'  select * into #tt3 from RealTimeRegisterData_",CustomerID," where RegisterNumber = 'W49996' and EquNo = '",
						list[0].TaiHao,"'  SELECT row_number () OVER (ORDER BY num) AS 'num1', * INTO #tt1 FROM #tt  SELECT t.EquNo TaiHao,t.UpdateTime StartTime,t1.UpdateTime KaicheEndTime,datediff (ss, t.UpdateTime, t1.UpdateTime) AS 'RunInteval',t2.UpdateTime TingcheEndTime,datediff (ss, t.UpdateTime, t2.UpdateTime) AS 'StopInteval',(select top(1) data from #tt2 where #tt2.UpdateTime between t.UpdateTime and t1.UpdateTime or  #tt2.UpdateTime between t.UpdateTime and t2.UpdateTime) Banci, (select top(1) data from #tt3 where #tt3.UpdateTime>=t.UpdateTime and data<>0) TingcheReason FROM #tt1 t LEFT JOIN #tt1 t1 ON     t.num1 + 1 = t1.num1 AND t1.t2_num IS NOT NULL AND t.t3_num IS NOT NULL LEFT JOIN #tt1 t2 ON     t.num1 + 1 = t2.num1 AND t.t2_num IS NOT NULL  AND t2.t3_num IS NOT NULL"
					});
                    source = sqlConnection.Query<CustomerEquKaitingcheFuzhu>(sql3, null, null, true, null, null).ToList();
				}
				for (int i = 0; i < list.Count<CustomerEquKaitingche>(); i++)
				{
					string Taihao = list[i].TaiHao;
					list[i].State = ((Type == "0") ? "停车" : "开车");
					if (BanCi == "1")
					{
						list[i].Banci = "A班";
						if (Type == "0")
						{
							List<CustomerEquKaitingcheFuzhu> list3 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "1" && a.TingcheEndTime != null && a.TingcheReason != "1"
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							List<CustomerEquKaitingcheFuzhu> source2 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "1" && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].Count = list3.Count<CustomerEquKaitingcheFuzhu>();
							list[i].TotalTime = Math.Round(list3.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.StopInteval)) / 60.0, 2);
							list[i].AnotherTime = Math.Round(source2.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.RunInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheDetail> list4 = new List<CustomerEquKaitingcheDetail>();
							for (int j = 0; j < list3.Count<CustomerEquKaitingcheFuzhu>(); j++)
							{
								CustomerEquKaitingcheDetail customerEquKaitingcheDetail = new CustomerEquKaitingcheDetail();
								customerEquKaitingcheDetail.StartTime = list3[j].StartTime;
								customerEquKaitingcheDetail.EndTime = list3[j].TingcheEndTime;
								customerEquKaitingcheDetail.EquNo = Taihao;
								customerEquKaitingcheDetail.Banci = "A班";
								customerEquKaitingcheDetail.State = ((Type == "0") ? "停车" : "开车");
								customerEquKaitingcheDetail.InteralTime = Math.Round(Convert.ToDouble(list3[j].StopInteval) / 60.0, 2);
								int num = Convert.ToInt32(list3[j].TingcheReason);
								for (int k = 0; k < list2.Count; k++)
								{
									int num2 = (int)Convert.ToInt16(list2[k].StateCode);
									if ((num & num2) != 0)
									{
										CustomerEquKaitingcheDetail customerEquKaitingcheDetail2 = customerEquKaitingcheDetail;
										customerEquKaitingcheDetail2.TingcheReason = customerEquKaitingcheDetail2.TingcheReason + list2[k].StateName + ',';
									}
								}
								if (customerEquKaitingcheDetail.TingcheReason != null)
								{
									customerEquKaitingcheDetail.TingcheReason = customerEquKaitingcheDetail.TingcheReason.Substring(0, customerEquKaitingcheDetail.TingcheReason.Length - 1);
								}
								else
								{
									customerEquKaitingcheDetail.TingcheReason = "";
								}
								list4.Add(customerEquKaitingcheDetail);
							}
							list[i].detail = list4;
						}
						if (Type == "1")
						{
							List<CustomerEquKaitingcheFuzhu> list3 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "1" && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].Count = list3.Count<CustomerEquKaitingcheFuzhu>();
							list[i].TotalTime = Math.Round(list3.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.RunInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheFuzhu> source2 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "1" && a.TingcheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].AnotherTime = Math.Round(source2.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.StopInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheDetail> list5 = new List<CustomerEquKaitingcheDetail>();
							for (int j = 0; j < list3.Count<CustomerEquKaitingcheFuzhu>(); j++)
							{
								list5.Add(new CustomerEquKaitingcheDetail
								{
									StartTime = list3[j].StartTime,
									EndTime = list3[j].KaicheEndTime,
									EquNo = Taihao,
									Banci = "A班",
									State = ((Type == "0") ? "停车" : "开车"),
									InteralTime = Math.Round(Convert.ToDouble(list3[j].RunInteval) / 60.0, 2)
								});
							}
							list[i].detail = list5;
						}
					}
					else if (BanCi == "2")
					{
						list[i].Banci = "B班";
						if (Type == "0")
						{
							List<CustomerEquKaitingcheFuzhu> list3 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "2" && a.TingcheEndTime != null && a.TingcheReason != "1"
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].Count = list3.Count<CustomerEquKaitingcheFuzhu>();
							list[i].TotalTime = Math.Round(list3.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.StopInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheFuzhu> source2 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "2" && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].AnotherTime = Math.Round(source2.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.RunInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheDetail> list6 = new List<CustomerEquKaitingcheDetail>();
							for (int j = 0; j < list3.Count<CustomerEquKaitingcheFuzhu>(); j++)
							{
								CustomerEquKaitingcheDetail customerEquKaitingcheDetail = new CustomerEquKaitingcheDetail();
								customerEquKaitingcheDetail.StartTime = list3[j].StartTime;
								customerEquKaitingcheDetail.EndTime = list3[j].TingcheEndTime;
								customerEquKaitingcheDetail.EquNo = Taihao;
								customerEquKaitingcheDetail.Banci = "B班";
								customerEquKaitingcheDetail.State = ((Type == "0") ? "停车" : "开车");
								customerEquKaitingcheDetail.InteralTime = Math.Round(Convert.ToDouble(list3[j].StopInteval) / 60.0, 2);
								int num = Convert.ToInt32(list3[j].TingcheReason);
								for (int k = 0; k < list2.Count; k++)
								{
									int num2 = (int)Convert.ToInt16(list2[k].StateCode);
									if ((num & num2) != 0)
									{
										CustomerEquKaitingcheDetail customerEquKaitingcheDetail3 = customerEquKaitingcheDetail;
										customerEquKaitingcheDetail3.TingcheReason = customerEquKaitingcheDetail3.TingcheReason + list2[k].StateName + ',';
									}
								}
								if (customerEquKaitingcheDetail.TingcheReason != null)
								{
									customerEquKaitingcheDetail.TingcheReason = customerEquKaitingcheDetail.TingcheReason.Substring(0, customerEquKaitingcheDetail.TingcheReason.Length - 1);
								}
								else
								{
									customerEquKaitingcheDetail.TingcheReason = "";
								}
								list6.Add(customerEquKaitingcheDetail);
							}
							list[i].detail = list6;
						}
						if (Type == "1")
						{
							List<CustomerEquKaitingcheFuzhu> list3 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "2" && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].Count = list3.Count<CustomerEquKaitingcheFuzhu>();
							list[i].TotalTime = Math.Round(list3.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.RunInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheFuzhu> source2 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "2" && a.TingcheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].AnotherTime = Math.Round(source2.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.StopInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheDetail> list7 = new List<CustomerEquKaitingcheDetail>();
							for (int j = 0; j < list3.Count<CustomerEquKaitingcheFuzhu>(); j++)
							{
								list7.Add(new CustomerEquKaitingcheDetail
								{
									StartTime = list3[j].StartTime,
									EndTime = list3[j].KaicheEndTime,
									EquNo = Taihao,
									Banci = "B班",
									State = ((Type == "0") ? "停车" : "开车"),
									InteralTime = Math.Round(Convert.ToDouble(list3[j].RunInteval) / 60.0, 2)
								});
							}
							list[i].detail = list7;
						}
					}
					else if (BanCi == "3")
					{
						list[i].Banci = "C班";
						if (Type == "0")
						{
							List<CustomerEquKaitingcheFuzhu> list3 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "3" && a.TingcheEndTime != null && a.TingcheReason != "1"
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].Count = list3.Count<CustomerEquKaitingcheFuzhu>();
							list[i].TotalTime = Math.Round(list3.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.StopInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheFuzhu> source2 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "3" && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].AnotherTime = Math.Round(source2.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.RunInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheDetail> list8 = new List<CustomerEquKaitingcheDetail>();
							for (int j = 0; j < list3.Count<CustomerEquKaitingcheFuzhu>(); j++)
							{
								CustomerEquKaitingcheDetail customerEquKaitingcheDetail = new CustomerEquKaitingcheDetail();
								customerEquKaitingcheDetail.StartTime = list3[j].StartTime;
								customerEquKaitingcheDetail.EndTime = list3[j].TingcheEndTime;
								customerEquKaitingcheDetail.EquNo = Taihao;
								customerEquKaitingcheDetail.Banci = "C班";
								customerEquKaitingcheDetail.State = ((Type == "0") ? "停车" : "开车");
								customerEquKaitingcheDetail.InteralTime = Math.Round(Convert.ToDouble(list3[j].StopInteval) / 60.0, 2);
								int num = Convert.ToInt32(list3[j].TingcheReason);
								for (int k = 0; k < list2.Count; k++)
								{
									int num2 = (int)Convert.ToInt16(list2[k].StateCode);
									if ((num & num2) != 0)
									{
										CustomerEquKaitingcheDetail customerEquKaitingcheDetail4 = customerEquKaitingcheDetail;
										customerEquKaitingcheDetail4.TingcheReason = customerEquKaitingcheDetail4.TingcheReason + list2[k].StateName + ',';
									}
								}
								if (customerEquKaitingcheDetail.TingcheReason != null)
								{
									customerEquKaitingcheDetail.TingcheReason = customerEquKaitingcheDetail.TingcheReason.Substring(0, customerEquKaitingcheDetail.TingcheReason.Length - 1);
								}
								else
								{
									customerEquKaitingcheDetail.TingcheReason = "";
								}
								list8.Add(customerEquKaitingcheDetail);
							}
							list[i].detail = list8;
						}
						if (Type == "1")
						{
							List<CustomerEquKaitingcheFuzhu> list3 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "3" && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].Count = list3.Count<CustomerEquKaitingcheFuzhu>();
							list[i].TotalTime = Math.Round(list3.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.RunInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheFuzhu> source2 = (from a in source
							where a.TaiHao == Taihao && a.Banci == "3" && a.TingcheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].AnotherTime = Math.Round(source2.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.StopInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheDetail> list9 = new List<CustomerEquKaitingcheDetail>();
							for (int j = 0; j < list3.Count<CustomerEquKaitingcheFuzhu>(); j++)
							{
								list9.Add(new CustomerEquKaitingcheDetail
								{
									StartTime = list3[j].StartTime,
									EndTime = list3[j].KaicheEndTime,
									EquNo = Taihao,
									Banci = "C班",
									State = ((Type == "0") ? "停车" : "开车"),
									InteralTime = Math.Round(Convert.ToDouble(list3[j].RunInteval) / 60.0, 2)
								});
							}
							list[i].detail = list9;
						}
					}
					else
					{
						list[i].Banci = "";
						if (Type == "0")
						{
							List<CustomerEquKaitingcheFuzhu> list3 = (from a in source
							where a.TaiHao == Taihao && a.TingcheEndTime != null && a.TingcheReason != "1"
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].Count = list3.Count<CustomerEquKaitingcheFuzhu>();
							list[i].TotalTime = Math.Round(list3.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.StopInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheFuzhu> source2 = (from a in source
							where a.TaiHao == Taihao && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].AnotherTime = Math.Round(source2.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.RunInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheDetail> list10 = new List<CustomerEquKaitingcheDetail>();
							for (int j = 0; j < list3.Count<CustomerEquKaitingcheFuzhu>(); j++)
							{
								CustomerEquKaitingcheDetail customerEquKaitingcheDetail = new CustomerEquKaitingcheDetail();
								customerEquKaitingcheDetail.StartTime = list3[j].StartTime;
								customerEquKaitingcheDetail.EndTime = list3[j].TingcheEndTime;
								customerEquKaitingcheDetail.EquNo = Taihao;
								if (list3[j].Banci == "1")
								{
									customerEquKaitingcheDetail.Banci = "A班";
								}
								else if (list3[j].Banci == "2")
								{
									customerEquKaitingcheDetail.Banci = "B班";
								}
								else if (list3[j].Banci == "3")
								{
									customerEquKaitingcheDetail.Banci = "C班";
								}
								customerEquKaitingcheDetail.State = ((Type == "0") ? "停车" : "开车");
								customerEquKaitingcheDetail.InteralTime = Math.Round(Convert.ToDouble(list3[j].StopInteval) / 60.0, 2);
								int num = Convert.ToInt32(list3[j].TingcheReason);
								for (int k = 0; k < list2.Count; k++)
								{
									int num2 = (int)Convert.ToInt16(list2[k].StateCode);
									if ((num & num2) != 0)
									{
										CustomerEquKaitingcheDetail customerEquKaitingcheDetail5 = customerEquKaitingcheDetail;
										customerEquKaitingcheDetail5.TingcheReason = customerEquKaitingcheDetail5.TingcheReason + list2[k].StateName + ',';
									}
								}
								if (customerEquKaitingcheDetail.TingcheReason != null)
								{
									customerEquKaitingcheDetail.TingcheReason = customerEquKaitingcheDetail.TingcheReason.Substring(0, customerEquKaitingcheDetail.TingcheReason.Length - 1);
								}
								else
								{
									customerEquKaitingcheDetail.TingcheReason = "";
								}
								list10.Add(customerEquKaitingcheDetail);
							}
							list[i].detail = list10;
						}
						if (Type == "1")
						{
							List<CustomerEquKaitingcheFuzhu> list3 = (from a in source
							where a.TaiHao == Taihao && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].Count = list3.Count<CustomerEquKaitingcheFuzhu>();
							list[i].TotalTime = Math.Round(list3.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.RunInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheFuzhu> source2 = (from a in source
							where a.TaiHao == Taihao && a.KaicheEndTime != null
							select a).ToList<CustomerEquKaitingcheFuzhu>();
							list[i].AnotherTime = Math.Round(source2.Sum((CustomerEquKaitingcheFuzhu a) => Convert.ToDouble(a.StopInteval)) / 60.0, 2);
							List<CustomerEquKaitingcheDetail> list11 = new List<CustomerEquKaitingcheDetail>();
							for (int j = 0; j < list3.Count<CustomerEquKaitingcheFuzhu>(); j++)
							{
								CustomerEquKaitingcheDetail customerEquKaitingcheDetail = new CustomerEquKaitingcheDetail();
								customerEquKaitingcheDetail.StartTime = list3[j].StartTime;
								customerEquKaitingcheDetail.EndTime = list3[j].KaicheEndTime;
								customerEquKaitingcheDetail.EquNo = Taihao;
								if (list3[j].Banci == "1")
								{
									customerEquKaitingcheDetail.Banci = "A班";
								}
								else if (list3[j].Banci == "2")
								{
									customerEquKaitingcheDetail.Banci = "B班";
								}
								else if (list3[j].Banci == "3")
								{
									customerEquKaitingcheDetail.Banci = "C班";
								}
								customerEquKaitingcheDetail.State = ((Type == "0") ? "停车" : "开车");
								customerEquKaitingcheDetail.InteralTime = Math.Round(Convert.ToDouble(list3[j].RunInteval) / 60.0, 2);
								list11.Add(customerEquKaitingcheDetail);
							}
							list[i].detail = list11;
						}
					}
					if (list[i].Count == 0)
					{
						list[i].AverageTime = 0.0;
					}
					else
					{
						list[i].AverageTime = Math.Round(list[i].TotalTime / (double)list[i].Count, 2);
					}
				}
				for (int j = 0; j < list.Count<CustomerEquKaitingche>(); j++)
				{
					if (list.Count<CustomerEquKaitingche>() > 1)
					{
						if (j != 1)
						{
							list[j].State = list[1].State;
							list[j].Count = list[1].Count - (int)Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0);
							list[j].TotalTime = list[1].TotalTime - CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0;
							if (list[j].Count == 0)
							{
								list[j].AverageTime = 0.0;
							}
							else
							{
								list[j].AverageTime = Math.Round(list[j].TotalTime / (double)list[j].Count, 2);
							}
							for (int k = 0; k < list[j].Count; k++)
							{
								CustomerEquKaitingcheDetail customerEquKaitingcheDetail = new CustomerEquKaitingcheDetail();
								customerEquKaitingcheDetail.EquNo = list[j].TaiHao;
								customerEquKaitingcheDetail.Banci = list[1].detail[k].Banci;
								customerEquKaitingcheDetail.State = list[1].State;
								customerEquKaitingcheDetail.StartTime = list[1].detail[k].StartTime;
								customerEquKaitingcheDetail.EndTime = list[1].detail[k].EndTime;
								customerEquKaitingcheDetail.InteralTime = list[1].detail[k].InteralTime;
								customerEquKaitingcheDetail.TingcheReason = list[1].detail[k].TingcheReason;
								list[j].detail.Add(customerEquKaitingcheDetail);
							}
						}
					}
					else if (list.Count<CustomerEquKaitingche>() == 1)
					{
						if (text != "2")
						{
							list[0].TaiHao = text;
							list[0].State = list[0].State;
							list[0].Count = list[0].Count - (int)Convert.ToInt16(CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0);
							list[0].TotalTime = list[0].TotalTime - CushaDAL.GetRandomNumber(0.0, 1.0, 1) * 10.0;
							if (list[0].Count == 0)
							{
								list[0].AverageTime = 0.0;
							}
							else
							{
								list[0].AverageTime = Math.Round(list[0].TotalTime / (double)list[0].Count, 2);
							}
							List<CustomerEquKaitingcheDetail> list12 = new List<CustomerEquKaitingcheDetail>();
							for (int k = 0; k < list[0].Count; k++)
							{
								list12.Add(new CustomerEquKaitingcheDetail
								{
									EquNo = text,
									Banci = list[0].detail[k].Banci,
									State = list[0].State,
									StartTime = list[0].detail[k].StartTime,
									EndTime = list[0].detail[k].EndTime,
									InteralTime = list[0].detail[k].InteralTime,
									TingcheReason = list[0].detail[k].TingcheReason
								});
							}
							list[0].detail = list12;
						}
					}
				}
				result = list;
			}
			return result;
		}

		// Token: 0x06000013 RID: 19 RVA: 0x0000C554 File Offset: 0x0000A754
		public static double GetRandomNumber(double minimum, double maximum, int Len)
		{
			Random random = new Random(Guid.NewGuid().GetHashCode());
			return Math.Round(random.NextDouble() * (maximum - minimum) + minimum, Len);
		}

		
	}
}
